Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

extensive page/site performance optimizations

  • Loading branch information...
commit fc8a94d7ff63faab3636a180d88edcb6b1e8e7ca 1 parent 206e364
@manuelkiessling authored
View
1  .htaccess
@@ -0,0 +1 @@
+AddType x-mapp-php5 .php .shtml .html .htm .txt .js .css .png .jpg .gif
View
18 footer.php
@@ -0,0 +1,18 @@
+<?php
+
+$output = ob_get_clean(); // Gesamte Ausgabe, die an den Client gesendet werden soll, abfangen und zwischenspeichern
+
+$etag = '"'.sha1($output).'"'; // Prüfsumme der Ausgabe berechnen// Ist der Inhalt identisch mit dem, den der Client gecached hat?
+
+if ($_SERVER['HTTP_IF_NONE_MATCH'] == $etag) // Wenn ja, dann sende nur den Status 304
+{
+ header('HTTP/1.x 304 Not Modified');
+ header('Etag: '.$etag);
+ die();
+}
+else // Wenn nicht, dann sende den Inhalt inkl. des neuen Etags
+{
+ header('Etag: '.$etag);
+ echo $output;
+ die();
+}
View
30 header.php
@@ -0,0 +1,30 @@
+<?php
+
+ob_start();
+
+$pathinfo = pathinfo($_ENV['SCRIPT_FILENAME']);
+$extension = $pathinfo['extension'];
+
+if ($extension != 'html') {
+ header('Cache-Control: max-age=604800'); // 1 week
+}
+
+if ($extension == 'css') {
+ header('Content-type: text/css; charset=utf-8');
+}
+
+if ($extension == 'js') {
+ header('Content-type: text/javascript; charset=utf-8');
+}
+
+if ($extension == 'png') {
+ header('Content-type: image/png');
+}
+
+if ($extension == 'jpg') {
+ header('Content-type: image/jpeg');
+}
+
+if ($extension == 'gif') {
+ header('Content-type: image/gif');
+}
View
85 index.html
@@ -371,36 +371,76 @@
display: none;
}
</style>
-
- <script type="text/javascript" src="mootools-core-1.3.1-full-compat-yc.js"></script>
- <script type="text/javascript" src="TOC.js"></script>
+
<script type="text/javascript">
- window.addEvent('domready', function() {
- var toc = new TOC('table-of-contents');
+ // Function to asyncronously load local js files
+ function loadScript(url, callback) {
+ var script = document.createElement("script")
+ script.type = "text/javascript";
+ script.async = true;
+
+ if (script.readyState){ //IE
+ script.onreadystatechange = function(){
+ if (script.readyState == "loaded" ||
+ script.readyState == "complete"){
+ script.onreadystatechange = null;
+ callback();
+ }
+ };
+ } else { //Others
+ script.onload = function(){
+ callback();
+ };
+ }
+
+ script.src = url;
+ document.getElementsByTagName("head")[0].appendChild(script);
+ }
+
+ // Table of Contents script
+ loadScript("mootools-core-1.3.1-full-compat-yc.js", function(){
+ loadScript("TOC.js", function(){
+ window.addEvent('domready', function() {
+ var toc = new TOC('table-of-contents');
+ });
+ });
});
- </script>
- <script type="text/javascript" src="prettify/prettify.js"></script>
- <script type="text/javascript">
+
+ // Code prettyfier
+ loadScript("prettify/prettify.js", function(){});
+
+ // Google Analytics
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-2127388-6']);
_gaq.push(['_trackPageview']);
- (function() {
+ function loadAnalytics() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
- })();
- </script>
- <script type="text/javascript">
- /* <![CDATA[ */
- (function() {
+ }
+ setTimeout(loadAnalytics, 1);
+
+ // Disqus
+ var disqus_shortname = 'nodebeginner';
+ var disqus_identifier = 'nodebeginner-book';
+ var disqus_url = 'http://www.nodebeginner.org/';
+ function loadDisqus() {
+ var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
+ dsq.src = 'http://mediacdn.disqus.com/1317948585/build/system/embed.js';
+ (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
+ }
+ setTimeout(loadDisqus, 1);
+
+ // Flattr
+ function loadFlattr() {
var s = document.createElement('script'), t = document.getElementsByTagName('script')[0];
s.type = 'text/javascript';
s.async = true;
s.src = 'http://api.flattr.com/js/0.6/load.js?mode=auto';
t.parentNode.insertBefore(s, t);
- })();
- /* ]]> */
+ }
+ setTimeout(loadFlattr, 1);
</script>
</head>
<body onload="prettyPrint();">
@@ -3094,21 +3134,10 @@
</div>
<div id="disqus_thread"></div>
- <script type="text/javascript">
- var disqus_shortname = 'nodebeginner';
- var disqus_identifier = 'nodebeginner-book';
- var disqus_url = 'http://www.nodebeginner.org/';
-
- (function() {
- var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
- dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
- (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
- })();
- </script>
<div id="footer">
<p id="ccimage">
- <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-nc-sa/3.0/88x31.png" /></a>
+ <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-nc-sa/3.0/88x31.png" width="88" height="31"/></a>
</p>
<p>
<span xmlns:dct="http://purl.org/dc/terms/">The Node Beginner Book</span>
View
4 php.ini
@@ -0,0 +1,4 @@
+short_open_tag=off
+output_handler=ob_gzhandler
+auto_prepend_file=/kunden/homepages/0/d271931425/htdocs/www.nodebeginner.org/header.php
+auto_append_file=/kunden/homepages/0/d271931425/htdocs/www.nodebeginner.org/footer.php
View
1  prettify/.htaccess
@@ -0,0 +1 @@
+AddType x-mapp-php5 .php .shtml .html .htm .txt .js .css .png .jpg .gif
View
4 prettify/php.ini
@@ -0,0 +1,4 @@
+short_open_tag=off
+output_handler=ob_gzhandler
+auto_prepend_file=/kunden/homepages/0/d271931425/htdocs/www.nodebeginner.org/header.php
+auto_append_file=/kunden/homepages/0/d271931425/htdocs/www.nodebeginner.org/footer.php
Please sign in to comment.
Something went wrong with that request. Please try again.