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.
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?
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.
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.