9

I am having an issue where the afterScriptsLoaded event is simply not firing on my <ltng:require /> component when I enable Locker Service. If that is calling a controller function that only does console.log('In After Loaded');, that log will never appear in the console despite all the scripts showing in the resources pane. If I disable Locker Service it shows right up as expected.

Has anyone else experienced this and more importantly, does anyone know a workaround?

1 Answer 1

9

The cases where we have seen this have all tracked back to the code being loaded failing to compile or execute because it either violates Locker (actually this has been rare) or it encounters classes, methods etc that are not currently exposed in Locker (almost 100% of the time). The afterScriptsLoaded= only runs if the code gets past compiling. If you have the browser's dev tools open and configured to break on all exceptions it should pinpoint the specific issue. Please let us know what you find. What libraries are you loading?

The good news is that we've spent the past 3 months working on a significant update to Locker that is scheduled to deploy to Winter'17 orgs on or near 10/18 and this set of fixes addressses almost all open cases/bugs.

2
  • Thanks for that info. It looks like jQuery 1.11.2 is causing the issue. This is an older version so I'll try using a newer version and also check back after 10/18. I think it might help a lot to add that behavior note to the doc at developer.salesforce.com/docs/atlas.en-us.lightning.meta/….
    – dsharrison
    Commented Oct 11, 2016 at 16:23
  • 1
    Just to follow up, what is the best channel to make an enhancement request for an onScriptLoadError event? I know that saying the lightning team has a lot going on right now is an understatement, but something like this could really help maintenance for developers down the road by allowing them to capture more information if a script stops loading.
    – dsharrison
    Commented Oct 11, 2016 at 19:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .