Skip to content

Best way to run code from newly added JS files by snippets #336

Answered by jiripudil
semisedlak asked this question in Support
Discussion options

You must be logged in to vote

Hello, I'm sorry you find the documentation lacking, but I'm afraid there's really not much more to it than what it already says 😟

As for loading third-party scripts, it's more convenient to implement it in an extension. Usually, third-party scripts pollute the global scope, so it's best to check for the existence of the API and load the script if it's not there. You can draw some inspiration from how I load Facebook SDK (beware, it uses Naja 1).

I also have an idea how to improve the current behaviour: the ScriptLoader could deduplicate loaded scripts by their id if present. I think that could help your use case. Would do you think?

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by jiripudil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Support
Labels
None yet
2 participants