반응형

Synchronized jQuery 1.10 and 2.0.1 Releases

 

http://www.infoq.com/news/2013/05/synchronized-jquery-releases

 

jQuery 1.10 and 2.0.1 has been released. The primary goal of this release is to synchronize the features of the 1.x and 2.x lines. The jQuery 2.x line has the same API as the 1.x line, but does not support Internet Explorer 6, 7, or 8. If you are planning to upgrade and you currently using jQuery 1.8 and below, please make sure you read the jQuery 1.9 Upgrade Guide due to major changes to the API. If you are already using jQuery 1.9 or jQuery 2.0, the latest versions should be a drop-in replacement. jQuery is provided under the MIT license.

Here are the highlights of this release.

Relaxed HTML Parsing
You can once again have leading spaces or newlines before tags in $(html). Remember that it's strongly advised that $.parseHTML() be used to parse HTML from external sources.
Increased Modularity
The .wrap(), .wrapAll(), .wrapInner() and .unwrap() methods are now optional, so you can create custom builds that excludes these methods. If your code is using the newer .on() event methods introduced in jQuery 1.7, you can also exclude .bind() and .delegate(). Please note that the releases on the jQuery, Google, and Microsoft CDNs continue to include all methods for maximum compatibility.
IE9 Focus of Death Fix
If a page inside an iframe attempts to focus an element, or even tries to read document.activeElement before the page is ready, it causes an error in IE9. The internal work around to this issue it to use native DOM .focus(). .
Cordova Fix
In jQuery 2.0.1, the Cordova deviceready event doesn't properly set an event target. This has been confirmed on the iPhone and Android with Cordova 2.5.0. The work around is to set the target to the document.

The complete jQuery 1.10 and 2.0.1 changelog can be found at the end of the release blog post.

jQuery 1.10 and 2.0.1 are now available on the jQuery CDN. The Google CDN and the Microsoft CDN are still hosting the previous versions as of this writing, so please check in a few days.

반응형
반응형

 

http://svgjs.com/

 

SVG.js is a lightweight JavaScript library for animating and manipulating SVG. It has an uncluttered syntax, is only 7k gzipped, has various useful plugins, and much more.

svg.js

반응형
반응형

Two.js is a two-dimensional drawing API that is built for modern web browsers. Since it’s renderer agnostic, the same API can draw in multiple contexts, including webgl, svg, and canvas.

two.js

반응형
반응형

Verlet-js — A JavaScript physics engine

Javascript/Added on May 15, 2013/Add to favorites

Verlet-js is a Verlet integration physics engine written in JavaScript and released under the MIT License. It can handle simulations, composites, particles, and constraints.

Verlet-js

Homepage: http://subprotocol.com/verlet-js/
GitHub: https://github.com/subprotocol/verlet-js

 

 

About

verlet-js a simple Verlet integration physics engine written in javascript by Sub Protocol. Verlet is pronounced 'ver-ley'.

Examples

  1. Shapes (Hello world)
  2. Fractal Trees
  3. Cloth
  4. Spiderweb

Features

The following is the entity hierarchy used within verlet-js:

  • Simulation: Root object that holds composite entities and drives all physics and animation within a scene.
  • Composites: A high level object used within the scene (ball, bridge, cloth, etc..)
  • Particles: Just a point in space that responds to gravity.
  • Constraints: Links particles together so they can interact with each other.
    1. Pin: Binds a particle to a static/fixes position in space.
    2. Distance: Binds two particles together by a fixed linear distance.
    3. Angle: Binds 3 particles to each other by an acute angle.

License

You may use verlet-js under the terms of the very permissive MIT License.

Source Code

View project on GitHub

 

 

반응형
반응형

7 CSS and JavaScript Performance Tips

 

http://webdesignledger.com/tips/7-css-and-javascript-performance-tips

 

Have you ever thought about how many customers you lose by having a slow site? And I’m not talking about file size only, as we rely on browser capacities to understand our code, we need to consider the processing time also.

That’s why sometimes adding a few bites in your code is much better because it save you precious seconds when real browsers or IE try to process your code.

Let’s see a few nice tips on how to improve this:

1. Don’t repeat yourself

You should use the cascade and avoid repeating code. It’s more than just using common classes, you could make good use of the heritance, for instance, so properties that can be set in the parent should be left there. Also you could use the same set of properties for multiple elements (separating multiple selectors using commas, you know).

Also, in your JS make good use of objects, functions and plugins so you don’t need to repeat code.

2. Write from right to left

Unlike us, browsers will process jQuery and CSS selectors from right to left. You may think that this won’t affect your code, but the truth is that it changes everything. A selector like this one is really, really bad:

$(“body #container div a”)

What we think we are writing is “Hey Browser, find the ‘body’ tag, and then inside of it find the #container. There you’ll find a ‘div’ and a couple of ‘a’ elements, let’s select those”. But the browser will actually read the entire page searching for ‘a’ tags, then for each tag it finds it’ll check if it has a div as parent, then check if the div has an element with the #container id, then
check if there’s a body tag beneath them.

7 CSS and JS performance tipsImage from Alex Anistratov

This is just too messy. In the JS we have some elegant solutions, like the find function so your code will actually be read as you wanted. Something like this would be good:

$(“#container”).find(“div”).find(“a”)

When you’re writing CSS you don’t have much options but leaving it as specific as possible, so try finding the closest class or ID you can find.

3. ID’s are really fast

Whenever possible use ID’s, they are faster either in CSS or JS. When using JS you have the possibility of using alternatives rather than jQuery to select tags, like document.body or even passing the entire DOM tree as an array (if you already know the exact location of the element).

4. Keep the selectors short

Keep in mind that sometimes an extra item in your selector will just mess up your code. For instance if you have a “ul li a” selector, you could simply use the “ul a” and you’ll be fine.

The best JS tip we can give you is “don’t use it”. Most times you simply don’t need it and using will cost you a lot more in performance, development time, browser compatibility and maintenance.

You can replace a lot of animations by CSS animations, and you could also use a library like yepnope or modernizr to conditionally load fallbacks for browsers that can’t keep up with your awesomeness.

6. You don’t need to declare your vars, but you should

A lot of people simply skip the var declaration step. That’s ok, but you’ll create a lot of global variables that can break other functionalities and also when the browser has to recover it, it’ll search from local to global scope.

Even if you’ll use a global scope var, you can redefine it locally so you’ll save some time. For example, instead of doing this:

var e1= document.getElementById('ID1'),
e2= document.getElementById('ID2');

Do this:

var doc= document,
e1= doc.getElementById('ID1'),
e2= doc.getElementById('ID2');

So you’ll locally store the document var

7. Do math like you do in your head

We tend to think that programming languages do some kind of black magic and give us the result of complex operations. But the truth is that every single operation has a processing cost. For example, instead of doing 2*15 it’s much easier to do 15+15.

The true tip in this case is, use the more native JS code as you can, so avoid relying on jQuery or other plugins because that will certainly take more time to load and often more code to write.

7 CSS and JS performance tipsImage from Kevin Andersson

BONUS: 8. Remove one image from your source code

The One Less JPG movement is right when they say that removing one image from your source code would save you far more bites than what you’d save by worrying about JS (and CSS). But the truth is: You should do both.

We should always do our best to improve user experience and if that means that an image will look good in the page, and the fancy JS animation has to be removed, so do it.

반응형
반응형

한 브라우저 내에서 도메인 swap  스크립트

북마크 URL에 넣어서 사용하면 된다.

 

 

Domain_A.com
Domain_B.co.kr

 

 

javascript:

var host = location.href;

if (host.indexOf("Domain_B.co.kr") >0) {

    host = host.replace("Domain_B.co.kr", "Domain_A.com")

} else {

    host = host.replace("Domain_A.com", "Domain_B.co.kr")

};

location.href = host;

 

 

javascript:var host = location.href;if (host.indexOf("Domain_B.co.kr") >0) { host = host.replace("Domain_B.co.kr", "Domain_A.com") } else { host = host.replace("Domain_A.com", "Domain_B.co.kr") }; location.href = host;

 

반응형
반응형

Maplace.js

 

A small Google Maps Javascript helper.

 

 

http://maplacejs.com/

 

Maplace.js helps you to embed Google Maps into your website, quickly create markers and controls menu for the locations on map.
It requires jQuery and Google Maps API v3 so you need to have both in your page.

Features

  • Straightforward implementation with simple options
  • Can run as many maps as required
  • Markers and custom icons, zoom level and custom controls menu
  • Supports for Directions, Polygons, Polylines, Fusion tables and styled maps
  • Works in all major browsers, including IE6 (this website not so much)
  • Released under the MIT license

 

 

 

반응형
반응형

JSDares — Learn JavaScript by programming games

Javascript - Reference/Added on May 6, 2013/Add to favorites

JSDares is a series of tutorials that will teach you step-by-step how to program JavaScript via game development. You complete “dares”, short puzzles, by copying the example with as few lines of code as possible. Right now it’s a proof of concept with examples, but soon there will be dare collections to start with.

JS Dares

 

반응형

+ Recent posts