1

I am trying to load RequireJS, a static resource, and it is failing to load into the Lightning application because the element is rendered incorrectly.

I'm using the LTNG:REQUIRE tag in this format:

<ltng:require scripts="{!$Resource.RequireJS}" src="{!$Resource.RequireJS}" afterScriptsLoaded="{!c.initTypeahead}" />

However when I look at the rendered HTML I see that it is not loading as a resource in the app because it is rendering as:

<script data-src="/resource/.../RequireJS"></script>

This is causing the app to fail as there is a big dependency on this JS file. Does anyone have an idea as to why "data-src" is rendered rather than "src"?

11
  • Why are you settting src attribute instead of <ltng:require scripts="{!$Resource.RequireJS}" afterScriptsLoaded="{!c.initTypeahead}" /> ?
    – Praveen
    Jul 14, 2016 at 17:19
  • Hi, I am not using src, i'm using <ltng:require scripts="{!$Resource.RequireJS}" afterScriptsLoaded="{!c.initTypeahead}" /> but it is not rendering correctly as stated in the issue. The tag should be rendered as <script src=.... but instead is rendered as <script data-src=....
    – Antonio
    Jul 14, 2016 at 17:38
  • I tried the same in my org its working fine and indeed it is rendered as <script data-src=.../> which not an issue at all.Are you getting any error message? Are you referencing the static resource path correctly?
    – Praveen
    Jul 14, 2016 at 18:19
  • Yes i'm getting an error message because a function which is in the RequireJS file is not recognized/available because the script is not loaded into the application, presumably because the src attribute is not rendered as src, but as data-src. @Praveen Are you able to use the RequireJS functions with the script referenced as data-src?
    – Antonio
    Jul 14, 2016 at 18:24
  • Can you check the status of the resources loaded in the Network tab of the chrome's developer tools ?
    – Praveen
    Jul 14, 2016 at 18:27

1 Answer 1

0

The resolution for me was to disable the new lightning security feature known as "LockerService" through the critical updates.

This may not be enabled in most orgs as of now, which is why this may have been a unique problem that only I was facing. But fair warning the feature will be auto-enabled for all orgs in Winter '17.

Documentation: Introducing Locker Service

You must log in to answer this question.

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