org.sonar.l10n.web.rules.Web.LongJavaScriptCheck.html Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sonar-web-plugin Show documentation
Show all versions of sonar-web-plugin Show documentation
Analyze HTML (also within PHP/Ruby/etc. templates) and JSP/JSF code.
The newest version!
Long pieces of JavaScript should be located in dedicated *.js source files.
This makes maintenance of both the script and the pages that use it easier.
Additionally, it offers some efficiencies in serving the files, since it takes better advantage of
browser caching to only re-serve the parts of a web page that have actually changed.
Noncompliant Code Example
<head>
...
<script type="text/javascript" language="JavaScript">
function doTheThing(arg1) {
...
...
}
function doTheOtherThing(arg1) {
...
}
function andSoOn() {
...
}
</script>
</head>
Compliant Solution
<head>
...
<script type="text/javascript" language="JavaScript" src="myLongScript.js"> </script>
</head>
© 2015 - 2025 Weber Informatics LLC | Privacy Policy