Skip to content

Commit

Permalink
Only use hyphenator.js on Chrome and Opera
Browse files Browse the repository at this point in the history
All the other major browsers support CSS3 hyphens which is significantly faster.  hyphenator.js is supposed to fallback to CSS3 on browsers that support it but testing has show it's still incredibly slow.
  • Loading branch information
brad-anderson committed Jul 16, 2013
1 parent c73a1f5 commit 357fbda
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 9 deletions.
4 changes: 0 additions & 4 deletions chmgen.d
Expand Up @@ -345,10 +345,6 @@ void main()
if (line.contains(`<script src="http://digg.com/tools/diggthis.js"`))
skip = true;

// skip hyphenation (bad performance in IE with large pages)
if (line.contains(`<script src="/js/hyphenate.js"`))
skip = true;

while (!skip && line.test(re_extern_js))
{
auto url = match.captures[1].replace(`\`, `/`);
Expand Down
19 changes: 18 additions & 1 deletion css/style.css
Expand Up @@ -13,6 +13,23 @@ body
margin: 0px auto;
}

.hyphenate
{
-webkit-hyphens: auto;
-moz-hyphens: auto;
-ms-hyphens: auto;
hyphens: auto;
}

.donthyphenate
{
-webkit-hyphens: manual;
-moz-hyphens: manual;
-ms-hyphens: manual;
hyphens: manual;
}


h1, h2, h3, h4, h5, h6
{
font-family: Georgia, "Times New Roman", Times, serif;
Expand Down Expand Up @@ -802,4 +819,4 @@ input.runButton:hover, input.resetButton:hover, input.argsButton:hover, input.in
input.runButton:active, input.resetButton:active, input.argsButton:active, input.inputButton:active, input.editButton:active
{ position: relative; top: 1px; }
input.resetButton{display: none}
/* Runnable-examples css -end */
/* Runnable-examples css -end */
2 changes: 1 addition & 1 deletion doc.ddoc
Expand Up @@ -26,7 +26,7 @@ DDOC=
<script src="/js/run-main-website.js" type="text/javascript"></script>
<script src="/js/d.js"></script>
<script src="/js/run.js" type="text/javascript"></script>
<script src="/js/hyphenate.js" type="text/javascript"></script>
<script src="/js/hyphenate-selectively.js" type="text/javascript"></script>

<script type="text/javascript">
function bodyLoad()
Expand Down
7 changes: 7 additions & 0 deletions js/hyphenate-selectively.js
@@ -0,0 +1,7 @@
// CSS hyphens is supported by IE10+, Firefox 6+, and Safari 5.1+ so only
// use hyphenator.js for Chrome where support is still missing completely (as
// of Chrome 29) and Opera (which now uses Chrome's rendering engine Blink).
var re = /(Chrome|Opera)/;
if (re.test(navigator.userAgent)) {
document.write('<script src="/js/hyphenate.js" type="text/javascript"></script>');
}
2 changes: 1 addition & 1 deletion posix.mak
Expand Up @@ -42,7 +42,7 @@ search-left.gif search-bg.gif search-button.gif tdpl.jpg \
ubuntu_logo.png win32_logo.png)

JAVASCRIPT=$(addprefix js/, codemirror.js d.js hyphenate.js \
run.js run-main-website.js)
hyphenate-selectively.js run.js run-main-website.js)

STYLES=css/style.css css/print.css css/codemirror.css

Expand Down
2 changes: 1 addition & 1 deletion std.ddoc
Expand Up @@ -56,7 +56,7 @@ DDOC = <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
<script src="/js/codemirror.js"></script>
<script src="/js/d.js"></script>
<script src="/js/run.js" type="text/javascript"></script>
<script src="/js/hyphenate.js" type="text/javascript"></script>
<script src="/js/hyphenate-selectively.js" type="text/javascript"></script>

<script type="text/javascript">
function listanchors()
Expand Down
2 changes: 1 addition & 1 deletion std_consolidated_header.dd
Expand Up @@ -9,7 +9,7 @@ Ddoc
<title>D Programming Language Standard Library</title>
<link rel="stylesheet" type="text/css" href="http://dlang.org/css/style.css">

<script src="/js/hyphenate.js" type="text/javascript"></script>
<script src="/js/hyphenate-selectively.js" type="text/javascript"></script>

</head>

Expand Down

0 comments on commit 357fbda

Please sign in to comment.