Quantcast
Channel: Opinion: Shopify Community - Shopify Apps
Viewing all articles
Browse latest Browse all 11091

Alex Farquhar commented on [JavaScript] Developing an App that inserts JavaScript

$
0
0

Hi Joel - does your script use jquery at all? The reason I ask is that if your script does something like this

$(function(){
foo();
})

then foo(); may never run because the page onload event would have already fired before your script is loaded. I'm not 100% sure this is the problem, but I ran into an issue where my (non-jquery) code was not firing due to the asynch script loading - my code was waiting for the onload to fire but this never happened!

Also my investigations suggest that you have no control over where or when your ScriptTag runs, because shopify uses the asynchload as shown in your post for all ScriptTag objects.

 

Hope that helps

Alex


Viewing all articles
Browse latest Browse all 11091

Trending Articles