-
-
Notifications
You must be signed in to change notification settings - Fork 45
Working with JavaScript
Chyrp Lite inlines all of its dynamic JavaScript in order to minimise page load times if the network connection has high latency or the server is resource-constrained. All scripts run in ECMAScript 5 strict mode for speed and security. A variety of triggers are provided to add custom JavaScript to your site.
If you want to add a dynamic script to a blog page or the admin console, the best way to do this is to respond to the trigger calls javascript
and admin_javascript
and send your script content to output. Several of Chyrp Lite's bundled modules use this method, for example the Cascade module.
If you want to add a static script to a blog page, you can respond to the trigger filter scripts
and provide the absolute path to your script file. To add your own static JavaScript to the admin console you can instead respond to the trigger call admin_head
and output a complete <script>
element.
jQuery will always be available, loaded statically from includes/common.js.
If you want to add a Content Security Policy to your site, Chyrp Lite provides two triggers so that you can allow its inline JavaScript.
With the trigger call javascripts_hash
you can generate a hash from the inline JavaScript content and declare this in your policy. With the trigger filter javascripts_nonce
you can set a nonce value for the inline JavaScript content and declare this in your policy.
This is the wiki for Chyrp Lite: An ultra-lightweight blogging engine, written in PHP.
- About Permissions
- Tour of a Theme
- Twig Reference
- Twig Variables
- Object Attributes
- Routes and Controllers
- Making Your First Module
- Debug and Tester Modes
- About Errors
- Introduction to Helpers
- Introduction to Translations
- Introduction to Triggers
- Anatomy of info.php Files
- Anatomy of a Feather
- Anatomy of a Module
- Anatomy of a Theme
- Anatomy of a Post
- Localizing Extensions
- Adding Ajax Functionality
- Working with JavaScript
- Working with Model
- Working with Config