Title: Problem with calling function from enqueued script.
Last modified: August 21, 2016

---

# Problem with calling function from enqueued script.

 *  Resolved [szaqal21](https://wordpress.org/support/users/szaqal21/)
 * (@szaqal21)
 * [12 years, 5 months ago](https://wordpress.org/support/topic/problem-with-calling-function-from-enqueued-script/)
 * 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">
       functionCall();
       </script>
       ```
   
 * 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.
 * [http://wordpress.org/plugins/assetsminify/](http://wordpress.org/plugins/assetsminify/)

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Plugin Author [Alessandro Carbone](https://wordpress.org/support/users/alecarbo/)
 * (@alecarbo)
 * [12 years, 5 months ago](https://wordpress.org/support/topic/problem-with-calling-function-from-enqueued-script/#post-4405108)
 * I’ll consider this for the next release of the plugin.
    Btw it is not a best 
   practice to embed js within HTML code. Bye.
 *  Thread Starter [szaqal21](https://wordpress.org/support/users/szaqal21/)
 * (@szaqal21)
 * [12 years, 5 months ago](https://wordpress.org/support/topic/problem-with-calling-function-from-enqueued-script/#post-4405111)
 * 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](https://wordpress.org/support/users/alecarbo/)
 * (@alecarbo)
 * [12 years, 5 months ago](https://wordpress.org/support/topic/problem-with-calling-function-from-enqueued-script/#post-4405112)
 * You are right: it is not necessary.
    It is a best practice 😉
 *  Thread Starter [szaqal21](https://wordpress.org/support/users/szaqal21/)
 * (@szaqal21)
 * [12 years, 5 months ago](https://wordpress.org/support/topic/problem-with-calling-function-from-enqueued-script/#post-4405115)
 * 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](https://wordpress.org/support/users/alecarbo/)
 * (@alecarbo)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/problem-with-calling-function-from-enqueued-script/#post-4405134)
 * 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. Bye.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Problem with calling function from enqueued script.’ is closed to new
replies.

 * ![](https://s.w.org/plugins/geopattern-icon/assetsminify.svg)
 * [AssetsMinify](https://wordpress.org/plugins/assetsminify/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/assetsminify/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/assetsminify/)
 * [Active Topics](https://wordpress.org/support/plugin/assetsminify/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/assetsminify/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/assetsminify/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [Alessandro Carbone](https://wordpress.org/support/users/alecarbo/)
 * Last activity: [12 years, 4 months ago](https://wordpress.org/support/topic/problem-with-calling-function-from-enqueued-script/#post-4405134)
 * Status: resolved