Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Firefox doesn't load script in template #465

Closed
JanMiksovsky opened this issue Apr 3, 2014 · 5 comments
Closed

Firefox doesn't load script in template #465

JanMiksovsky opened this issue Apr 3, 2014 · 5 comments
Assignees
Labels

Comments

@JanMiksovsky
Copy link

See http://jsbin.com/huhis/1/edit. This logs the string "loaded" to the console in Chrome, Canary, and Safari — but not Firefox. (Separate bug: This displays "loaded" twice in Safari.

Background: I came across this case in trying to use a defer attribute on a script required by a analytics beacon element that would only be instantiated once per page. I wanted:

  • The beacon element to load its own script (rather than requiring the outer page to load the script separately)
  • The analytics script to be deferred to avoid delaying rendering of the page
  • Some work to be done after the deferred script eventually loaded.

I couldn't work out how to sink an event handler on the script element's load event if the script tag were outside the template. I tried putting the script tag within the template, and that at least let me sink load with on-load="{{loadedHandler}}". This worked everywhere in Firefox, which I isolated to the jsbin above.

@dfreedm
Copy link
Member

dfreedm commented Apr 4, 2014

Script seems to work when cloning a template directly: http://jsbin.com/kesepoca/1/edit

I wonder if this has to do with ShadowDOM polyfill?

@dfreedm
Copy link
Member

dfreedm commented Apr 4, 2014

Btw, I assume safari displays 'loaded' twice because we have to polyfill template element, and we can't polyfill the "script doesn't run" behavior, as the parser executes the script before the polyfill can touch the containing template element.

@sjmiles
Copy link
Contributor

sjmiles commented Apr 4, 2014

Also btw, 'loaded twice' shouldn't happen in a import, where we can control parsing.

@tjsavage tjsavage added the p1 label Aug 21, 2014
@tjsavage tjsavage added this to the beta milestone Aug 21, 2014
@tjsavage tjsavage added the 0.5 label May 21, 2015
@sorvell sorvell removed the p1 label Jun 25, 2015
@tjsavage
Copy link
Contributor

Closing this issue due to age and the release of version 1 of Polymer - please feel free to re-open if this is incorrect.

@halfstrik
Copy link

Still <script> does not get executed if placed inside any custom element in FF (in my case, in <paper-material>). But works in Chromium.
Polymer versions tried: 1.1.3 and latest 1.2.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants