Support » Plugin: AssetsMinify » Problem with calling function from enqueued script.

  • Resolved szaqal21


    Plugin has hardcoded “async” attribute for script tag in function footerServe() and when I want to call a function from minified asset (right after minified asset script tag)

    <script async="" src="https://xyz/wp-content/uploads/am_assets/foot-63d925416ac7d2177826e375e86529d2.js" type="text/javascript">
    <script type="text/javascript">

    I get an error about that the function is undefined.

    When I’ve removed async attribute from script tag every thing worked fine. Please add some option or a filter to give possibility to modify this behaviour.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Alessandro Carbone


    I’ll consider this for the next release of the plugin.
    Btw it is not a best practice to embed js within HTML code.

    I know but I don’t think it is necessary to create a seperate JS file just to call some init functions like Shadowbox.init() that’s why I’m embedding this in HTML code and several others init’s.

    Plugin Author Alessandro Carbone


    You are right: it is not necessary.
    It is a best practice 😉

    But isn’t including js code as separate files slower than including it in HTML (in cases like I mentioned above)? Could you give me some hints where to read more about it? I’ve read that it is better to limit the number of external files. Thanks

    Plugin Author Alessandro Carbone


    Hi, new version released v1.2.2.
    Now you can enable async from backend.
    Btw, yes if you include multiple js files it is slower than including in HTML, but the best solution to achieve good performance and clean code is to compress the scripts with 1 single file and not to embed js script directly in the HTML files.
    Yes, it is better to limit the number of external files using js compression and minification. AssetsMinify does all of this.
    If you like, please review my plugin.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Problem with calling function from enqueued script.’ is closed to new replies.