background preloader

Minify JavaScript - Free JavaScript Compressor

Minify JavaScript - Free JavaScript Compressor
Related:  Learning JS

Control Flow in Node Part II Static Version I had so much fun writing the last article on control flow, that I decided to play around with the feedback I received. One thing in particular I want to talk about is the good work inimino is doing. Node has two constructs that are used currently to handle async return values, namely callbacks and event emitters. UPDATE Promises were removed from node a while back, this article has been updated to show callbacks instead of promises. Why the distinction between Callback and EventEmitter? In node there are two event handling techniques. callback.js var fs = require('fs'); fs.readFile('mydata.txt', function (err, buffer) { if (err) { // Handle error console.error(err.stack); return; } // Do something console.log(buffer);}); fs.readFile() takes a filename and "returns" the contents of the file. Sometimes you want to listen for events that can happen several times. http-body.js var http = require('http'); console.log("Server started on continuable.js do.js

10 strike plan to grease your site for speed. - Webdistortion I’ve recently spoke of the importance of speed with your website or blog. It can have a significant impact on site goals, and in many cases improve bounce rates and increase page views. Paying attention to detail and improving page load speed can really get your pages performing at their optimum. 1) All Sites – on page speed Javascript Google host a variety of popular javascript libraries for web developers, and this standardised hosting platform provides a central repository for developers. This has a couple of benefits. 2) Images There are a number of way to optimise images for speed. I’ve found in the past the compression engine within Fireworks to be superior to Photoshop when analysing quality verses size. 3) Lowering web requests Web requests are individual web page calls to a web server for a file. You should do everything in your power to lower the number of requests that you make – the lower that number the better. 4) Client Side Compression 5) Server Side Compression Cache Plugins

jquery parse json multidimensional array Control Flow in Node Static Version One of the unique aspects of programming in an async framework like node is the ability to decide between which function will run in serial and which will run in parallel. While there are no built-in methods for managing this in node, I'll discuss some of the tricks I came up with while writing the node-blog engine that generates this site. Parallel vs Serial Usually in an application you have steps that can't run until the result from a previous step is known. This is the case in Node too, except for functions that would otherwise perform blocking IO. For my blog engine I have a tree structure of files that need to be processed. Get a list of articles.Read in and parse the articles.Get a list of authors.Read in and parse the authors.Get a list of HAML templates.Read in all the HAML templates.Get a list of static resource files.Read in the static files.Write article html pages.Write author pages.Write index page.Write feed page.Write static resources. simple-scanner.js

How do I force SSL on my ASP/.NET site on Cloud Sites? Below are three examples of how to force SSL on your ASP or ASP.NET site. web.config If your website has the IIS Rewrite Module available*, you can use rewrite rules in your web.config to force SSL on all pages: Please contact support if you are unsure if the IIS Rewrite Module is available for your site. The above example could be modified to force SSL on one page or specific pages. ASP.NET (Non MVC 3) Using ASP.NET you can use this code snippet to force SSL on a page on your site: When using the "RequireHttps" attribute to decorate actions within your MVC application: Classic ASP Using classic ASP you can use this code snippet to force SSL on a page on your site: © 2011-2013 Rackspace US, Inc. Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License See license specifics and DISCLAIMER

jQuery: The Write Less, Do More, JavaScript Library Prototypal Inheritance Static Version In almost all modern programming languages we use the concept of Object Oriented Programming (OOP) to help manage the complexity of today's software. The biggest challenge in modern software is in fact managing the complexity of it. Most languages do this with a variant OOP called Classical OOP. This is the one you see in Java, C#, C++, PHP, Ruby, and Python. While this is a great abstraction, I would like to experiment with other ideas. So what does JavaScript have? From what I hear (I wasn't there at the time), JavaScript was initially a prototypal inheritance system. Classical OOP classical.js var frank = new Person("Frank Dijon");frank.greet(); Output => 'Hello world, my name is Frank Dijon' Here we have a class like object Person. Prototypal OOP I don't like the new keyword, it overloads the meaning of functions and is dangerous. Instead try this on for size: prototypal.js#intro-to-style There is more you can set, but value and enumerable are the interesting ones.

ASP.NET - Browser speed on localhost Don't let jQuery's $(document).ready() slow you down jQuery’s $(document).ready() event is something that you probably learned about in your earliest exposure to jQuery and then rarely thought about again. The way it abstracts away DOM timing issues is like a warm security blanket for code running in a variety of cold, harsh browser windows. Between that comforting insurance and the fact that deferring everything until $(document).ready() will never break your code, it’s understandable not to give much thought to its necessity. However, what if $(document).ready() is slowing you down? Example: live() One of the most popular uses for jQuery’s live() is to maintain event handlers on elements that are dynamically created and destroyed over time. Imagine that we have an application with several slideToggling sidebar blocks which may be dynamically added and removed while the user interacts with the page. <html><head><script type="text/javascript" src="jquery.js"></script><script type="text/javascript"><! Benefit: A more responsive UI Conclusion

What is "this"? Static Version Most people that learn JavaScript are coming from a background in another language. This brings with it a view of how the world works that may be different from how it really works in JavaScript. It's all about where you are. In all programming languages, there is this idea of current scope and current context. In JavaScript all new scopes are created through "function" definitions. This is an example of global scope: global.js // Define a couple of global variablesvar name = "Tim";var age = 28; // Access one of them from the global scopename; Output => 'Tim' This is an example of local scope: local.js // Create a couple of local variables in a function.function newScope() { var name = "tim"; var age = 28;}// Try to access the local variables from the global scope// This will cause an error.name; Error ReferenceError: name is not defined Lexical Scope Lexical scope is the key to making closures work. So what does all that mean? lexical.js ReferenceError: other is not defined closure.js

How can I test PHP mail functionality? | Cloud Computing and Web Hosting Knowledge Center by Rackspace You can use the following code saved into a file with a .php extension to test PHP mail functionality: IMPORTANT NOTE: We strongly recommend using an SMTP relay that requires authentication. Sending mail through unauthenticated SMTP servers (including the localhost relay on Cloud Sites) can result in delays or undelivered email due to stringent anti-spam filters. Or you can use this test code: © 2011-2013 Rackspace US, Inc. Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License See license specifics and DISCLAIMER

Related: