You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+31-1Lines changed: 31 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,36 @@
2
2
3
3
jQuery.Syntax is a light-weight client-side syntax highlighter, which dynamically loads external dependencies (JavaScript & CSS) when required. It uses jQuery to make it cross-browser compatible and to simplify integration and integration with other systems.
4
4
5
+
## Motivation
6
+
7
+
jQuery.Syntax was built at a time when syntax highlighting on the web was a bit of a mess - browser incompatibilities and limitations made it hard to do the right thing consistently. Rather than a single definition of "good", presenting code nicely in a browser was dictated by a set of trade-offs.
8
+
9
+
At the time, syntax highlighters were often all-or-nothing - this made it cumbersome for sites that only had a few pages with code on them. jQuery.Syntax was designed from the ground up to use dynamic loading of assets when required. On top of that, the implementation was built using a profiler and is fairly efficient.
10
+
11
+
It's a good library and it's fast, that's why I continue to maintain and develop it.
12
+
13
+
### Isn't jQuery big?
14
+
15
+
Your right, small is pretty subjective.
16
+
17
+
jQuery as a dependency is based on a design from 2012. When browsers were a bit less "compatible", this was a good trade-off. These days, it could probably be removed, but it isn't worth the effort and for me personally it's a zero-cost dependency since I use it anyway on most of my sites.
18
+
19
+
The library is modular and only loads exactly the CSS and JS required. The minimised and gzipped library is 1.6Kbytes, this provide the top-level API and the dynamic loading functionality.
20
+
21
+
To highlight anything, you need to load the core parser and renderer code. It's 4.1Kbytes minified and gzipped. The CSS and Script files are tiny, most less < 1Kbyte, per language.
22
+
23
+
### Compared to xyz?
24
+
25
+
All syntax highlighters are pretty good these days. But, there are some key differences worth considering:
26
+
27
+
- How much does it load by default, even when not highlighting anything?
28
+
- How efficient/fast is it when highlighting code?
29
+
- How does line wrapping work?
30
+
- Can you embed `<span>` and `<a>` elements?
31
+
- Can it handle embedded code (e.g. JavaScript inside HTML)?
32
+
- Is it easy to install?
33
+
- Is it easy to customize?
34
+
5
35
## Installation
6
36
7
37
jQuery.Syntax is easily installed using bower.
@@ -12,7 +42,7 @@ It has a `dist/` directory which follows standard conventions.
12
42
13
43
### Advanced Configuration
14
44
15
-
jQuery.Syntax compiles and minifies it's code using uses Rake (Ruby) and [Sass](http://sass-lang.com). Please review the included `Rakefile` for more details.
45
+
jQuery.Syntax compiles and minifies it's code using uses Rake (Ruby) and [Sass](http://sass-lang.com). Please review the included `Rakefile`and `install.yaml`for more details.
0 commit comments