I’m wondering if it’s ok to load the Finsweet Attributes scripts I need for some pages using an embed instead of putting them in the HTML head tag. I need the same scripts on about half of my website pages, and I would hate to put them in the Page head tag for each page and then realize I need to change one thing across all pages.
Hey @jon.thomas! I don’t see a reason why this wouldn’t work. If you face any issue please let me know
Great! Some pages I need to defer and prevent load, and on others I don’t, so this is going to be very helpful
Do you see any advantage to putting the embed that calls the scripts after the opening body tag vs. before the closing body tag?
Using Chat-GPT as an info source:
For most cases where performance is key and unless there’s a need for early script execution, placing the scripts before the closing
</body>
tag is recommended. It provides a better user experience by allowing the content to load first and keeps scripts from blocking rendering. However, if you need to initialize critical scripts right away (e.g., handling above-the-fold content or managing important features like cookie consent), placing them after the opening<body>
tag might be better.
Shoot. Using an embed on the page comes before jQuery, which I reference in some of the Attributes API code.
Can you share a link? I’ll take a look
I decided to add the scripts page-by-page for the time being. If I decide to go the other route, I will resurrect this and troubleshoot more.
It does make me wonder though… can you use jQuery in a page embed if it is invoked before the jQuery source reference which Webflow appears to load last? I’ll have to do some testing there.
Thank you for the help!
From the Webflow forums: How can I write jQuery in page custom code or embed code? - #2 by samliew - Custom code - Forum | Webflow
Thanks for the extra info @jon.thomas!
Seems that JS is the best way to go for embeds