Javascript News

Syndicate content
Pipes Output
Updated: 48 weeks 6 days ago

Video: Understanding webpagetest.org

Do, 2015-07-09 22:00

In this video I'll walk through webpagetest.org, explaining what to look for when evaluating a site for performance. I'll also mispronounce the url a few times, sorry about that.

Loading the player...

Continue reading %Video: Understanding webpagetest.org%

Goodbye Joyent, Hello Node.js Foundation

Do, 2015-07-09 20:00

Last December, the world of server-side JavaScript was forever changed with the release of io.js. Since its release, io.js has had an immediate impact on the world of server-side JavaScript as it created an alternative platform to Joyent’s Node.js, or more simply known as Node. Those behind io.js built the platform to stay current with the latest features of the v8 JavaScript engine, something that Node.js failed to do. As a result of io.js’ impact, Joyent decided to give up sole ownership of the project to the Node.js foundation, a third-party made up of developers from some of the world’s top technology companies. Although the Node.js foundation continuously reached out to io.js to merge back with its predecessor, it would ultimately be a few months before io.js agreed to merge with the Node.js foundation. It will operate under the name Node.js.

To help you get the most complete overview on the success of io.js, in this article I will discuss what sparked the creation of the new platform, the key individuals behind it, and the governance model which I believe made this project so unbelievably successful.

What Sparked io.js

Oddly enough, many of the core developers at Joyent were behind the creation of io.js as a result of a bit of discord between the development team building the platform, and the administration in charge of implementing new builds. To help solve this problem, the developers at Joyent worked to craft a new model as background to develop the Platform. However, their conversations with the administration went nowhere. Often, developers working on the Node.js platform would have to watch the code to which they dedicated a great deal of time sit on a shelf which was disheartening. As time continued, tension continued to grow. Things changed when Fedor Idutny, a core developer at Node, took the liberty to fork Node.js, thus marking the creation of io.js. Idutny knew that he had the support of colleagues, and was confident that the project would be successful in providing a platform which supplied the latest support for ES6 on the server-side.

Continue reading %Goodbye Joyent, Hello Node.js Foundation%

More Tips to Further Secure WordPress

Do, 2015-07-09 19:00

WordPress has often been seen as the unofficial scapegoat to blame various security breaches on. Like many other popular web applications, WordPress is an attractive target for attack. Obviously, the security in WordPress, as with any application, needs to be put into context. Luckily, WordPress benefits from a wide variety of security configuration options and third party plugins to help satisfy those who are looking to increase their overall security.

In this article, I'm going to add to Tim Carr’s 10 Tips to Secure WordPress with even more ways you can help secure your site, starting prior to the WordPress installation.

Continue reading %More Tips to Further Secure WordPress%

Video: CSS Backgrounds

Do, 2015-07-09 18:00

The CSS background-image property allows us to apply one or more background images to any HTML element. In this video I will explain how to use the property, including how to write URL values correctly, and how to write local and absolute paths to images.

This is one lesson from my Getting Started with CSS course on Learnable. If you enjoyed the video, check out the course. See you there!

Loading the player...

Continue reading %Video: CSS Backgrounds%

How to Build a Targeted Email List With Facebook and Quizzes

Do, 2015-07-09 15:31

You may have heard the saying “The money’s in your email list.” It’s true. Email is still one of the cheapest and most effective forms of online marketing; therefore, it should be high on your list of distribution strategies. Two questions remain though: How do you build a list quickly if you aren’t getting much […]

Continue reading %How to Build a Targeted Email List With Facebook and Quizzes%

CSS Gradients: A Syntax Crash Course

Do, 2015-07-09 15:00

In the past most websites used images heavily to create a fancy UI. Thanks to various CSS properties this trend has changed. This tutorial will help you to learn about CSS gradients.You can use gradients to replace images in various UI elements as well as in backgrounds. With a little practice you can create complex patterns without using a single image.

CSS gradients, which have excellent browser support, allow you to create smooth visual transitions between two or more specified colors. Gradients give you control over a lot of settings like the size of the gradient, its angle, position of color stops, etc.

In this post, I’ll cover linear, radial, as well as the newer repeating gradients.

Linear Gradients

Linear gradients are the most commonly used gradients. The looks like this, with the bracketed values representing the types of values:

[code language="css"]
.example {
background: linear-gradient(
[direction], [first-color], [second-color], [more-colors ...]
);
}
[/code]

If you don’t specify a direction, the gradient will start at the top with full strength of the first color then smoothly transition to the last color as it reaches the bottom.

For more control, you can specify the direction of gradient. You can do it either by using simple terms like to left, to bottom right, or you can specify angles. Here is the code snippet to create a background that goes from left to right:

[code language="css"]
.example {
background: linear-gradient(to right, hotpink, lightpink);
}
[/code]

See the Pen Left to Right Linear Gradient by SitePoint (@SitePoint) on CodePen.

Older browsers support a slightly different syntax and require browser specific prefixes. In older browsers, instead of specifying the end point you specify a start point. CSS3 gradient code for older browsers looks like this:

[code language="css"]
.example {
background: -prefix-linear-gradient(left, red, blue);
}
[/code]

Specifying Angles for Linear Gradients

If you need to create a gradient at a specific angle, you can specify one directly. The code below creates a gradient at an angle of 60 degrees.

[code language="css"]
.example {
background: linear-gradient(60deg, red, blue);
}
[/code]

Considering a line from bottom to top to be at zero degrees, the angle increases if the line moves in a clockwise direction. For instance:

[code language="css"]
.example {
background: linear-gradient(0deg, red, blue);
}
[/code]

This will create a gradient with red at the bottom and blue at the top. While the following will create a horizontal gradient with red on the left side and blue on the right:

[code language="css"]
.example {
background: linear-gradient(90deg, red, blue);
}
[/code]

See the Pen Linear Gradients with Different Angles by SitePoint (@SitePoint) on CodePen.

Specifying Color Stops in Linear Gradients

If you want to change the colors non-uniformly you can specify color stops yourself. Position of color stops can be specified as a percentage value or an absolute length. You don’t need to specify the stop position for first and last color. A given color is at its full strength on the position that you specified. Here, is an example:

[code language="css"]
.example {
background: linear-gradient(
to bottom, yellow, red 70%, black
);
}
[/code]

If there are no stops specified, the colors will be spaced evenly.

See the Pen Linear Gradient with Color Stops by SitePoint (@SitePoint) on CodePen.

Radial Gradients

Radial gradients are less common and more complex. This is the syntax for radial gradients:

Continue reading %CSS Gradients: A Syntax Crash Course%

Structuring CSS Class Selectors with Sass

Do, 2015-07-09 14:00

CSS naming conventions are legions. You probably know BEM and SMACSS already (the latter also being more than naming conventions). There is also OOCSS which is more like a full methodology. They all heavily rely on CSS class selectors, as they are heavily re-usable.

Using Sass can help writing those selectors in a more modular fashion. through selector nesting and mixins, we can come up with fancy crazy solutions to build the desired API. In this article, I"ll (re-)introduce a few of these ways, listing what I feel are the pros and cons of each of them.

Native Selector Nesting

Having a way to nest selectors in order not to have to repeat the original block name has been a long asked feature in Sass. In version 3.3 of Sass, this feature has finally been introduced. First with a very odd syntax during the beta, later changed for a better one when the stable version went live. The reasons behind this change are explained by Natalie Weizenbaum in this article.

Basically, the reference selector (&) can be used as part of a sub-class name in order to create another class name from the first at root-level of the document (meaning @at-root is not needed here).

Continue reading %Structuring CSS Class Selectors with Sass%

When Are Green Pastures Not Actually Green?

Do, 2015-07-09 01:33

As big coffee drinkers at SitePoint, we also churn through a crate of milk each week. Recently the milk company we use rebranded. Here's the new label.

If it is possible for a brain to 'wince', mine did when I saw this. In fact, my brain still winces every time I see this milk bottle.

There's no question that 'Green Pastures' is a perfectly respectable name for any dairy product. The phrase conjures visions of peaceful, contented cows grazing lazily in lush fields.

High-fives on the naming workshop, guys!

However, how they settled on the idea of using a dry, dusty brown to portray their 'green pastures' label – the color of droughts, deserts and sun-baked clay – is one of life's great mysteries. It's great to be brave in design, but you need to be careful you aren't undermining your message.

While some people feel the sensation more acutely than others, most of us feel some sense of mental discomfort when we notice oddities like this. Psychologists call this discomfort 'cognitive dissonance' – an idea that was first described by Leon Festinger.

Festinger theorized that when people encounter it they will usually:

  1. Try to remove or resolve the discomfort
  2. Avoid that discomfort in future

Our milk tastes fine and since it is delivered to the fridge, I use it. But would I select it from a supermarket shelf? No, not if I had a choice. Sure, it's just a printed sticker but it just feels a little bit wrong.

Strangely, this even happens when random, accidental dissonances arise.

[caption id="attachment_110071" align="alignright" width="257"] Scrum cover in red and green[/caption]

I'm currently working on the book cover for 'Scrum: Novice to Ninja' by M. David Green. Clearly David is 'Green' by surname only, and not hue (He may or may not be 'politically green').

Yet when I composited his name onto an orange background it felt weird. At first I couldn't even figure out why, but somewhere my subconscious seemed to be elbowing me impatiently. Eventually my conscious mind 'got' it too.

When I switched the orange to a green, it was like shaking a stone out of my shoe. It fixed things.

Even watching the animation above, I still get the same feeling. Weird, huh?

Don't Dis' Dissonance

Does this doesn't mean that you should always avoid cognitive dissonance at all costs?

No. In fact, the entire mechanic of games like Farmville, Sim City and even ol' school Mouse Trap board game is built around using your own discomfort to draw you deeper into the game.

You invest some time and then have a choice. To do nothing and gradually lose what you have. Or invest more time, protect what you have and obtain more - even if the 'more' you obtain is of no tangible value.

After all, you reason, it would be crazy to let those virtual eggplants just wither on the vine because you didn't harvest them in time, right? After all those hours you've spent...

Providing ways for casual gamers to soothe their 'pyschic discomfort' is how Zynga was to able to rake in tens of millions of dollars a day in 2010-11. They didn't even need to offer things like interesting gameplay, hand-eye co-ordination challenges or even fun.

In truth, not many people ever talked about loving the experience of playing Farmville – they just preferred it over what happens when they stop playing and their farm dies.

So, it turns out that if you harness it correctly, cognitive dissonance can be a really useful force to move and motivate people who are already engaged in your site, app, game, etc.

But it can be much more damaging if it emerges during the introduction of your product/service. At that time the easiest way to soothe their discomfort is to choose another milk company.

Dissonance is a dark and powerful force. Use it wisely.

Continue reading %When Are Green Pastures Not Actually Green?%

PHP vs Node.js Smackdown: Right of Reply

Do, 2015-07-09 01:00

In SitePoint's recent PHP vs Node.js Smackdown, Craig Buckler pitted these development disciplines against each other over a series of ten challenges, to determine which is the overall winner.

As Craig notes in the article, these comparisons are always somewhat controversial. As a fun followup, we asked Bruno Škvorc (SitePoint's PHP editor) and James Hibbard (one of SitePoint's JavaScript editors) to provide a commentary on each of the rounds.

Here's their blow-by-blow assessment …

Round 1: Getting Started

Round 1's challenge was to see how quickly you can build a “Hello World” web page in each language. This included the time taken to set up a server environment.

In Craig's estimation, PHP won the round, partly because it's "conceptually simpler" and "less daunting to new developers".

Bruno:

PHP wins in "getting started" purely because more hosts have made it so easy to get started. It's a matter of adoption rather than anything else. If more hosts bypassed the need to use the command line with Node and went straight to file uploads and a simple "reload app" button in a control panel, they would be equal. The actual syntax of getting something to display on screen, however, is much simpler in PHP -- especially to those new to programming.

James:

When developing locally, I don't see a huge difference between the two. To run a PHP script in your browser, you need to have some kind of server stack installed; to run a Node script, you need to have installed Node, and preferably a web framework such as express. However, as Craig says, PHP is conceptually simpler. Node's barrier to entry is higher. No debate there.

Round 2: Help and Support

Round 2 looked at how easy it is to get help and support with each language. PHP wins this round, mainly because of its longevity.

Bruno:

Bruno kept silent on this one.

James:

I agree with this. Node.js is a younger technology, so currently, there is less help available. This will, however, become less and less of a consideration as Node matures.

Continue reading %PHP vs Node.js Smackdown: Right of Reply%

11 Best jQuery Charting Libraries

Mi, 2015-07-08 20:00

If you've worked with any kind of data, you know how harrowing reading rows and rows of numbers can be. It isn't easy to wade through all of those numbers and easily figure out what they mean. That's the case where visualisation comes to the rescue. Visualisation de-mystifies the data and helps decision makers derive actionable insights from it.

"Dataviz" is the abbreviation of "Data visualization" whose primary goal is

to communicate information clearly and efficiently to users via the statistical graphics, plots, information graphics, tables, and charts selected.

Wikipedia

As developers, we've to ensure that we use the right tools to create meaningful charts from the data, in a way that provides the appropriate amount of details while keeping an eye on the big picture.

There are many jQuery plugins charts available that can help you to create interactive dataviz for your web page. But which ones really deliver value? In this article I've rounded up my favorites and highlighted which scenario each is best suited for. In this way you won't waste time and effort searching for them and will have an accurate outline of your current possibilities of choice.

Continue reading %11 Best jQuery Charting Libraries%

Building a WordPress Carousel Plugin: Part 1

Mi, 2015-07-08 19:00

In this 3 part series, we will take a look at how to build a WordPress carousel plugin using the WordPress Links Manager API.

As we saw when we introduced it, the Links Manager is the best way to manage a list of links in WordPress. Its API doesn't contain many functions, but there are enough to be able to develop some useful applications.

We won't use wp_list_bookmarks(), we'll be using other functions we saw in our previous article.

If you're not already familiar with the WordPress Links Manager and its API, then you may need to have a look at both of these articles mentioned above first, before continuing to build your carousel.

Carousels are not a rare thing on the web, and that's why I thought it is interesting to see how to build one. It is also a good way to test our knowledge of the WordPress Links Manager API, so why not?

Continue reading %Building a WordPress Carousel Plugin: Part 1%

Improving Responsive Web Design With RESS

Mi, 2015-07-08 17:00

On average, more than one in three visitors to your website is using a mobile device. In the past year alone, mobile usage has increased by more than 20%. So how do we cater for this market?

Separate Mobile Websites

If your time, budget and sanity aren't important, you can build separate sites for mobile and desktop users. Content can be repackaged and streamlined for the device. Unfortunately…

  1. The days of either desktop or mobile are long gone. There is a huge variety of devices with differing screen sizes, pixel densities, processing speeds, network capabilities and HTML5 features. And few of us consider wearables yet! Would two or three sites to cater for every eventually? Ideally, you need dozens.
  2. Identifying the user's device is difficult. User-agent strings are notoriously tricky to parse and won't tell you anything about the screen dimensions, network speed or other features.
  3. You normally require separate URLs for each site, e.g. www.site.com and m.site.com. Users can end up on the wrong site for their device and, if you're not careful, search engines will penalize you for duplicate content.
  4. Managing one website is tough. You now need to build and deploy several sites and ensure they're updated concurrently. Perhaps your developers will survive the ordeal but will content editors cope with multiple assets which target different views?

That said, separate sites remains an attractive option for companies such as Amazon and eBay since it offers a targeted experience.

Responsive Web Design

Alternatively, designers and developers can use designs which respond to the browser's viewport dimensions (typically, the whole screen on smaller devices). Using a mobile-first approach, the site implements a default linear layout perhaps with smaller text and menus accessed from hamburger icons. As the dimensions increase, the design can be re-flowed to show additional columns, larger fonts, more spacing, always-visible menus etc.

RWD solves many issues encountered with separate views. We have a single site with one set of content which can respond to an infinite variety of screen sizes. Unfortunately…

Continue reading %Improving Responsive Web Design With RESS%

The Pathway for New Rubyists

Mi, 2015-07-08 14:00

One interesting fact about the Ruby ecosystem is its hyperactive nature. New updates, features, and tutorials spring up almost everyday. This makes the ecosystem interesting and fun, yet it could bring untold harm to new Ruby programmers. It is possible to get lost in the volatile nature of this interesting community without a sense of direction.

This is one article I wished had been written before I ventured into Ruby programming. I am writing this to help new Ruby programmers from encountering the challenges I faced by suggesting books, courses, blogs, and forums which, in my opinion, can be instrumental on their journey.

The community that grows up around a programming language is one of its most important strengths. Ruby has a vibrant and growing community that is friendly towards people of all skill levels. - Ruby-lang.org

Continue reading %The Pathway for New Rubyists%

Versioning: Behind the Scenes

Mi, 2015-07-08 08:29

TL:DR – we launched a newsletter, people liked it, more people liked it, a few more people liked it, we launched a website, people liked it? WL:HOD (Way Longer, Heaps of Detail) – read on… First Version: Alliteration, animation, and cake Early May, 2014 Good morning/greeting-appropriate-to-your-timezone, and welcome to the first ever Versioning. The Version […]

Continue reading %Versioning: Behind the Scenes%

SitePoint Smackdown: PHP vs Node.js

Mi, 2015-07-08 03:30

The web is ever-changing technology landscape. Server-side developers have a bewildering choice of long-standing heavy-weights such as Java, C, and Perl to newer, web-focused languages such as Ruby, Clojure and Go. It rarely matters what you choose, presuming your application works.

But how do those new to web development make an informed choice?

I hope not to start a holy war, but I'm pitting two development disciplines against each other:

  • PHP
    PHP was created by Rasmus Lerdorf in 1994. It is processed by an interpreter normally installed as a module in a web server such as Apache or Nginx.

    PHP code can be intermingled with HTML. That's not necessarily best-practice, but those new to the language can produce useful code very quickly. It contributed to the language's popularity, and PHP is now used on more than 80% of the world's web servers. It has been helped in no small part by WordPress -- a PHP Content Management System which powers a quarter of all sites.

  • Node.js
    Node.js was created by Ryan Dahl in 2009. It uses Google's V8 JavaScript engine, which also powers client-side code in the Chrome web browser. Unusually, the platform has built-in libraries to handle web requests and responses -- you don't need a separate web server or other dependencies.

    Node.js is relatively new but has been rapidly gaining traction. It's used by companies including Microsoft, Yahoo, LinkedIn and PayPal.

Where's C#, Java, Ruby, Python, Perl, Erlang, C++, Go, Dart, Scala, Haskell, etc?

An article which compared every option would be long. Would you read it? Do you expect a single developer to know them all? I've restricted this smackdown to PHP and Node.js because:

  1. It's a good comparison. They're both open source, primarily aimed at web development and applicable to similar projects.
  2. PHP is a long-established language but Node.js is a young upstart receiving increased attention. Should PHP developers believe the Node.js hype? Should they consider switching?
  3. I know and love the languages. I've been developing with PHP and JavaScript since the late 1990s, with a few years of Node.js experience. I've dabbled in other technologies, but couldn't do them justice in this review.

Besides, it wouldn't matter how many languages I compared. Someone, somewhere, would complain that I hadn't included their favorite!

About SitePoint Smackdowns

Developers spend many years honing their craft. Some have languages thrust upon them, but those who reach Ninja level usually make their own choice based on a host of factors. It's subjective; you'll promote and defend your technology decision.

That said, SitePoint Smackdowns are not "use whatever suits you, buddy" reviews. I will make recommendations based on my own experience, requirements and biases. You'll agree with some points and disagree with others; that's great -- your comments will help others make an informed choice.

Evaluation Methodology

PHP and Node.js are compared in the following ten rounds. Each bout considers a general development challenge which could be applied to any web technology. We won't go too deep; few people will care about the relative merits of random number generators or array sorting algorithms.

The overall winner will be the technology which wins the most rounds. Ready? Let the battle commence …

Continue reading %SitePoint Smackdown: PHP vs Node.js%

The Future of SEO

Mi, 2015-07-08 02:45

This article was sponsored by Crowdsearch. Thank you for supporting the sponsors who make SitePoint possible.

I love what Guy Kawasaki said in his baccalaureate speech to the 1995 graduating class at Palo Alto High School. No, I wasn’t there, but thanks to the Internet, we can time-travel back and gain from his insight.

In what later became his 10 Commandments of Innovation, point #8 of his speech— “Challenge the Known and Embrace the Unknown”—speaks to the future of SEO.

One of the biggest mistakes you can make in life is to accept the known and resist the unknown. You should, in fact, do exactly the opposite: challenge the known and embrace the unknown.

Let me tell you a short story about ice. In the late 1800s there was a thriving ice industry in the Northeast. Companies would cut blocks of ice from frozen lakes and ponds and sell them around the world. The largest single shipment was 200 tons that was shipped to India. 100 tons got there unmelted, but this was enough to make a profit.

These ice harvesters, however, were put out of business by companies that invented mechanical ice makers. It was no longer necessary to cut and ship ice because companies could make it in any city during any season.

These ice makers, however, were put out of business by refrigerator companies. If it was convenient to make ice at a manufacturing plant, imagine how much better it was to make ice and create cold storage in everyone’s home.

You would think that the ice harvesters would see the advantages of ice making and adopt this technology. However, all they could think about was the known: better saws, better storage, better transportation.

Then you would think that the ice makers would see the advantages of refrigerators and adopt this technology. The truth is that the ice harvesters couldn’t embrace the unknown and jump their curve to the next curve.

Challenge the known and embrace the unknown, or you’ll be like the ice harvester and ice makers.

Disruptive Technology

Harvard Business School professor Clayton M. Christensen coined the term in his 1997 best-selling book, The Innovator’s Dilemma. Disruptive technology displaces established technology, shakes up industries or creates completely new ones. It’s digital cameras displacing film. It’s PCs displacing typewriters then becoming displaced by mobile devices.

It’s the iPhone displacing Blackberry and creating an industry of app developers. It’s Google displacing Yellow Pages and creating the SEO industry.

Is SEO “Evolving” or Being Disrupted?

“SEO isn’t dead; it’s just evolving.” So say the multitude of SEOs and Internet marketers. (Heck, I’ve said it myself.) But perhaps it’s neither dead nor evolving.

Case in point. Google’s Hummingbird “update” wasn’t an update at all. It was a fundamental change in how their algorithm processes information. It’s the first step towards Google becoming an answer engine instead of a search engine. Sounds more like disruption than evolution.

Think about it. Every person who types a phrase in Google’s search box is looking for an answer to a question or a problem. For example, earlier today I typed do i need to cover my air conditioner in the winter. That’s because mine died and after spending too much money on a new one, I want to be sure I take care of it. (BTW, the answer is “no.” Question answered, problem solved.)

Voice search applications like Siri and Google Now are making conversational queries more common. It’s teaching us to ask questions rather than type a string of keywords.

And search engines are continually adapting to encourage these new habits. For instance, did you know that a simple setting in Google Chrome enables hands-free, desktop voice search?

Natural Language Processing, Semantic Search and Artificial Intelligence

Natural language processing (NLP) is the ability of a computer program to understand human speech as it is spoken. NLP is a field of artificial intelligence and linguistics concerned with the interactions between computers and human natural languages. As such, it will be the driving force behind the advancement of semantic search.

Semantic search is rooted in semantics, a sub-discipline of linguistics that studies the relationships between words and how we construct meaning. Semantic search attempts to understand the meaning of the query and searcher’s intent.

Was this Google’s purpose behind Hummingbird, artificial intelligence?

Continue reading %The Future of SEO%

Video: Enums in Swift

Mi, 2015-07-08 02:00

Loading the player...

In this video I'll be speaking about enums in Swift.

Continue reading %Video: Enums in Swift%

10 Ways to Minimize Reflows and Improve Performance

Di, 2015-07-07 18:00

Despite web pages reaching 2MB performance remains a hot topic. The slicker your application, the better the user experience and the higher the conversion rate!

That said, I'm guilty of adding superficial CSS3 animations or manipulating multiple DOM elements without considering the consequences. Two terms are used in the browser world when visual affects are applied:

Repaints
A repaint occurs when changes are made to elements that affect visibility but not the layout. For example, opacity, background-color, visibility, and outline. Repaints are expensive because the browser must check the visibility of all other nodes in the DOM -- one or more may have become visible beneath the changed element.

Reflows
Reflows have a bigger impact. This refers to the re-calculation of positions and dimensions of all elements, which leads to re-rendering part or all of the document. Changing a single element can affect all children, ancestors, and siblings.

Both are browser-blocking; neither the user or your application can perform other tasks during the time that a repaint or reflow occurring. In extreme cases, a CSS effect could lead to slower JavaScript execution. This is one of the reasons you encounter issues such as jerky scrolling and unresponsive interfaces.

It's useful to understand when reflows are triggered:

Adding, removing or changing visible DOM elements
The first is obvious; using JavaScript to change the DOM will cause a reflow.

Adding, removing or changing CSS styles
Similarly, directly applying CSS styles or changing the class may alter the layout. Changing the width of an element can affect all elements on the same DOM branch and those surrounding it.

CSS3 animations and transitions
Every frame of the animation will cause a reflow.

Using offsetWidth and offsetHeight
Bizarrely, reading an element's offsetWidth and offsetHeight property can trigger an initial reflow so the figures can be calculated.

User actions
Finally, the user can trigger reflows by activating a :hover effect, entering text in a field, resizing the window, changing the font dimensions, switching stylesheets or fonts.

The reflow processing flow hit will vary. Some browsers are better than others at certain operations. Some elements are more expensive to render than others. Fortunately, there are several general tips you can use to enhance performance.

1. Use Best-Practice Layout Techniques

I can't believe I need to say this in 2015 but don't use inline styles or tables for layout!

An inline style will affect layout as the HTML is downloaded and trigger an additional reflow. Tables are expensive because the parser requires more than one pass to calculate cell dimensions. Using table-layout: fixed can help when presenting tabular data since column widths are based on the header row content.

Continue reading %10 Ways to Minimize Reflows and Improve Performance%

What’s new in Firefox OS?

Di, 2015-07-07 17:00

Although Google and Apple have been able to hold an iron grip over the mobile duopoly in the last years, alternatives constantly kep emerging, trying to loosen this grip. Compared to Android or iOS, they have had moderate success, but as standalone initiatives, CyanogenMod, Firefox OS, Tizen and others offered a refreshing new perspective with great promise.

While struggling to have a noticeable impact, Firefox OS has come a long way since it debuted in 2013 (let's not forget Android in its early years). While I still consider 2014 as a rollercoaster year for Mozilla, 2015 won't be far behind. Changes, internal and external news are bound to shape Firefox OS's future, some in the short term.

Let's recapture the most important news about Firefox OS in the past months.

Continue reading %What’s new in Firefox OS?%

Atomic OOBEMITSCSS

Di, 2015-07-07 14:00

People love naming things. And developers love acronyms. And thus here we are, finding ourselves with all of these CSS naming conventions and methodologies: BEM, SMACSS, Point North, ITCSS, OOCSS, Title CSS, Idiomatic CSS, Atomic Design, SUIT CSS, Kickoff CSS, etc.

We often hear "Are you using OOCSS or BEM?” but these things are not mutually exclusive. In fact, most of the time, we’re taking concepts and ideas of the aforementioned ideologies, and mixing them up, customizing them to suit (no pun intended) our own needs.

So what have I been using these days? Well that would be Atomic OOBEMITSCSS. Yep. Atomic OOBEMITSCSS.

The first time I heard this ridiculous term was from a tweet via Dan Eden, who tweeted:

Continue reading %Atomic OOBEMITSCSS%