rspec/rules/S1456/html/rule.adoc
Fred Tingaud 16f6c0aecf
Inline adoc when include has no additional value (#1940)
Inline adoc files when they are included exactly once.

Also fix language tags because this inlining gives us better information
on what language the code is written in.
2023-05-25 14:18:12 +02:00

67 lines
1.1 KiB
Plaintext

== Why is this an issue?
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
With the default parameter value of 5:
[source,html]
----
<head>
...
<script type="text/javascript" language="JavaScript"> <!-- Noncompliant -->
function doTheThing(arg1) {
...
...
}
function doTheOtherThing(arg1) {
...
}
function andSoOn() {
...
}
</script>
</head>
----
=== Compliant solution
[source,html]
----
<head>
...
<script type="text/javascript" language="JavaScript" src="myLongScript.js"> </script>
</head>
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
The length of this JS script (XXX) exceeds the maximum set to YYY.
=== Parameters
.maxLines
****
----
5
----
Max Lines (Number)
****
endif::env-github,rspecator-view[]