Jump to content

Declined on loading CSS/JS


Recommended Posts

Hello,


I have my module declined with 'You must not load your CSS/JS directly but use the addCSS / addJS methods.'. Of course, most of the time I use addCSS/addJS methods. I spotted one place in the code where this message can refer to. I would like to know if that makes sense. 
I have a TPL template with the javascript definition and loading of jquery.js. I can move that code to a separate JS file and load it along with the jquery using addJS. However, in any case I will need to use some variables from PHP context in that javascript file. I didn't find any better way to do it but to define these variables in the TPL template (using smarty assign to pass it from PHP) and use them later in javascript context. But in that case I still need <script> tags inside TPL. Something like this:
<script>
    myapp_var="{$myapp_var|escape:'htmlall':'UTF-8'}";
</script>
Could it be considered loading the script directly and be the reason for decline?
In any case, is there any better and cleaner way to pass PHP variables to the javascript file loaded with addJS?
Thanks
 
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...