Title: Syntax error if linking external?
Last modified: September 3, 2017

---

# Syntax error if linking external?

 *  Resolved [auludag](https://wordpress.org/support/users/auludag/)
 * (@auludag)
 * [8 years, 9 months ago](https://wordpress.org/support/topic/syntax-error-if-linking-external/)
 * hi,
 * while adding a JS code, if i choose linking as external, I get error:
 * > Uncaught SyntaxError: Unexpected token <
 * such code is below.
 * `<script src="https://example.com/bugsnag-3.min.js"data-apikey="XXXXX"> </script
   >`
 * but if I add as inline, the error disappears.
 * Should i add JS code as a HTML code if i want to add external?
    -  This topic was modified 8 years, 9 months ago by [auludag](https://wordpress.org/support/users/auludag/).

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

 *  Plugin Author [SilkyPress](https://wordpress.org/support/users/diana_burduja/)
 * (@diana_burduja)
 * [8 years, 9 months ago](https://wordpress.org/support/topic/syntax-error-if-linking-external/#post-9464101)
 * Linking an external JS should be done as a HTML code. Your code example is a 
   piece of HTML code that links a JS code.
 * If you read the default comments in the editor on the “Add HTML Code” page, then
   you’ll see an example similar to yours.
 *  Thread Starter [auludag](https://wordpress.org/support/users/auludag/)
 * (@auludag)
 * [8 years, 9 months ago](https://wordpress.org/support/topic/syntax-error-if-linking-external/#post-9464765)
 * thank you. what is your personal opinion about internal vs external? would you
   suggest adding js codes inline or external speaking for WordPress? How performance
   would be affected for the plugin or site?
 *  Plugin Author [SilkyPress](https://wordpress.org/support/users/diana_burduja/)
 * (@diana_burduja)
 * [8 years, 9 months ago](https://wordpress.org/support/topic/syntax-error-if-linking-external/#post-9464839)
 * I usually use inline linking for small pieces of codes (10 lines or less) and
   external linking for bigger JavaScript codes.
 * If it is a small piece of code, then it doesn’t make sense to let the browser
   create another connection with the server. It is more economical to write the
   JavaScript it directly in the HTML.
 * If it is a bigger piece of code, then it’s better to let the browser create another
   connection with the server and afterwards cache the linked file. You don’t need
   to do anything for the browser’s cache of JavaScript files, this is done automatically.
 *  Thread Starter [auludag](https://wordpress.org/support/users/auludag/)
 * (@auludag)
 * [8 years, 9 months ago](https://wordpress.org/support/topic/syntax-error-if-linking-external/#post-9466998)
 * Thank you for reply.
 * According to your last reply, I think I should call scripts above who is used
   for calling a JS files externally. Though they seem only 1 line, they are used
   for calling JS files from some other site, and that JS that is called is huge–
   i mean above maybe 100 lines.
 * I hope my approach is correct.

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

The topic ‘Syntax error if linking external?’ is closed to new replies.

 * ![](https://ps.w.org/custom-css-js/assets/icon-128x128.png?rev=1303730)
 * [Simple Custom CSS and JS](https://wordpress.org/plugins/custom-css-js/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/custom-css-js/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/custom-css-js/)
 * [Active Topics](https://wordpress.org/support/plugin/custom-css-js/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/custom-css-js/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/custom-css-js/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [auludag](https://wordpress.org/support/users/auludag/)
 * Last activity: [8 years, 9 months ago](https://wordpress.org/support/topic/syntax-error-if-linking-external/#post-9466998)
 * Status: resolved