critical.js – View
crit namespace, for example:
critical.js is an open-source project, licensed under the MIT license. Click here for the full text of the license.
To use critical.js, download critical-min.js and link to it (in the HEAD section of your HTML file, before any other code) like this:
There are 19 functions as of critical.js 0.5 (the current beta). They are as follows:
- Is a replacement for the native typeof function, as it doesn't support arrays or null.
- Clones an object, instead of leaving a reference to it.
- Returns all but a certain index of an array or string as a new object.
- Runs a function on each item of an array, and returns a new object.
- Counts the occurrence of a value in an array or string.
- Works similar to the indexOf method of strings and arrays, except this function finds the nth index of a value, not only the first.
- Returns a random item from an array.
- Scrambles an array or string, and returns a new object.
- Prints an array in an easily read format.
- Returns a new string, the reverse of the one supplied.
- Returns a new string that is the original repeated.
- Returns a new string without surrounding whitespace.
- Replaces newlines with HTML linebreaks (<br/>).
- The binary value of a Boolean.
- Returns a number with the timezone offset from UTC in hours.
- Returns the full month name.
- Returns the short month name.
- Returns the full day name.
- Returns the short day name.