Merge pull request #2732 from Firesphere/patch-1

MINOR Documentation slightly improved for js inclusion
This commit is contained in:
Will Rossiter 2013-12-20 15:40:49 -08:00
commit b47e1e0b7f

View File

@ -139,11 +139,15 @@ to change inclusion-order, other than using *Requirements::clear* and rebuilding
requirements. Caution: Inclusion order is both relevant for CSS and Javascript files in terms of dependencies,
inheritance and overlays - please be careful when messing with the order of Requirements.
NOTE:
By default, SilverStripe includes all Javascript files at the bottom of the page body. If this causes problems for you,
### Javascript placement
By default, SilverStripe includes all Javascript files at the bottom of the page body, unless there's another script already loaded, then, it's inserted before the first `<script>` tag. If this causes problems for you,
for example if you're using animation that ends up showing everything until the bottom of the page loads, or shows
buttons before pushing them will actually work, you can change this behaviour through
the `Requirements.write_js_to_body` configuration setting.
buttons that rely on Javascript to work, you can change this behaviour. See below.
With the `Requirements.write_js_to_body`, you can configure if Javascript requirements are written to the head (false) or body (true).
With the `Requirements.force_js_to_bottom`, you can force Silverstripe to write the Javascript to the bottom of the page body, even if there is an earlier script tag. For example, when you have asynchronous scripts for Twitter earlier in your body (and stop speedtests from explaining about "scripts above the fold")
## CMS Requirements