Tag Archives: london

Introducing Mavo: Create Web Apps Entirely By Writing HTML!

Have you ever wanted to make a website that non-technical folks can edit right in the browser? Or have you ever wanted to make a website that presents an editable collection of items (e.g. your portfolio)? Or simply upload images to a website you made, right from the browser?

Introducing Mavo: Create Web Apps Entirely By Writing HTML!

Well, what if I told you, that you can do these things (and more!), just with HTML and CSS? No programming code to write, no servers to manage. You can make any element editable and saveable just by adding one HTML attribute to it. In fact, you can store your data locally in the browser, on Github, on Dropbox, or any other service just by changing an HTML attribute.

The post Introducing Mavo: Create Web Apps Entirely By Writing HTML! appeared first on Smashing Magazine.

Original post – 

Introducing Mavo: Create Web Apps Entirely By Writing HTML!

The Top 10 Most Common AdWords Mistakes (And How To Fix Them)

Top 10 Google Adwords Mistakes

AdWords can be an incredibly powerful platform for growing your business, but the truth is that most businesses are wasting thousands of dollars every month due to poor account management. If you feel like you could be generating more revenue from AdWords, chances are that you’re making some of these ten common mistakes that are inhibiting your performance. In this post I will be showing you ten common AdWords mistakes that I’ve seen literally hundreds of advertisers make. And, more importantly, I’m going to show you exactly how to fix them, so you can take next steps towards creating an…

The post The Top 10 Most Common AdWords Mistakes (And How To Fix Them) appeared first on The Daily Egg.

Excerpt from – 

The Top 10 Most Common AdWords Mistakes (And How To Fix Them)

The 17 Best Digital Marketing Conferences of 2017

conference-attendees-best-marketing-conference-feature

Does the word conference bring up memories of suited professionals droning on about… well, you can’t quite remember what? Awkward socializing, shameless sales pitching, lined paper and branded pens — some conferences can be very beige indeed.

But not all conferences are made equal. In fact, some can lead you to completely change your marketing game for the better by giving you the opportunity to learn firsthand the tricks of the trade from the smartest minds in digital marketing — from SEO royalty Rand Fishkin to Unbounce co-founder Oli Gardner.

We worked our way through the colossal number of upcoming digital marketing conferences to uncover the gems and roundup what we think are the 17 best digital marketing conferences in 2017.

Warning: what you see and learn at these events may totally transform the way you do your digital marketing.

Conference Date Location
SearchLove February 23-24; June 5-6; October 16-17 San Diego; Boston; London, UK
Domopalooza March 21-24 Salt Lake City
ConversionXL Live April 5-7 San Antonio
Hero Conf April 18-20; October 23-25 Los Angeles; London, UK
Marketing United April 19-21 Nashville
Marketing Nation April 23-26 San Francisco
C2 Montreal May 24-26 Montreal, QC
WistiaFest June 11-13 Boston
Unbounce Call To Action Conference June 25-27 Vancouver, BC
MozCon July 17-19 Seattle
Content Marketing World September 5-8 Cleveland
Dmexco Conference September 13-14 Cologne, DE
INBOUND September 25-28 Boston
B2B Forum October 3-6 Boston
RD Summit November 2017 Brazil
Dreamforce November 6-9 San Francisco
Internet Summit November 15-16 Raleigh
Advocamp December 6-8 San Francisco

1. SearchLove: February 23-24 (San Diego) | June 5-6 (Boston) | October 16-17 (London)

searchlove

SearchLove is the creation of online marketing agency Distilled. As the name implies, this conference is all about search marketing; topics covered span from SEO to PPC and content creation. Over two days, learn actionable tactics to get your website ranking higher. Sessions run one after the other, so you won’t have to miss out on anything.

2. Domopalooza: March 21-24 (Salt Lake City)

domopalooza

This one made its way onto our list, as the content is worth more than gold to any marketer who wants to step up their data game. The organizers, Domo, are business intelligence wizards and creators of a data-driven business management platform.

If you fancy going deep into business analytics and learning how to get data insights to inform your marketing activities and your business as a whole, check Domopalooza out. Plus, with performances from Flo Rida, T.I. and Nelly last year, the entertainment bar is set dang high for 2017.

3. ConversionXL Live: April 5-7 (San Antonio)

conversionxl

CXL Live promises to help marketers achieve their ultimate goals: drive more conversions, grow their businesses faster and make more dough. How? Attendees get the opportunity not only to watch “hardcore practitioners” wax lyrical about conversion marketing, they can also chat to the pros in person.

The event lasts three whole days — plenty of time to get as much advice as you need from your favorite conversion marketing experts and start racking up leads like a true conversion pro.

4. Hero Conf: April 18-20 (Los Angeles)  | October 23-25 (London)

heroconf

Not to be confused with a gathering for superheroes of the comic book kind, Hero Conf is “the world’s largest all-PPC event”.

If you’re a pay-per-click fanatic, this one’s for you. Make connections with the best in the PPC business and learn how to optimize your PPC campaigns; for example, which strategies and trends can help you drive more conversions. Besides, when else could you chat about your favorite subject over some nosh with PPC industry experts?

5. Marketing United: April 19-21 (Nashville)

marketingunited

Marketing United is a digital marketing showdown hosted by email marketing connoisseurs Emma. This will be Emma’s third event and, like its previous events, it promises to be full of “ah-hah” moments spanning all areas of digital marketing such as marketing psychology, customer experience and brand building.

Attendees can expect to marvel at inspiring presentations from a killer lineup including speakers from Netflix and Pixar. They will also get the chance to discover the vibrant and unique city of Nashville, renowned for live country music and an iconic food scene (bring on the fried chicken!).

6. Marketing Nation: April 23-26 (San Francisco)

marketingnation

Marketo’s four-day event will equip you with the knowledge you need to improve the way you interact with customers and help you get better results from your marketing efforts. You can also improve your knowledge of Marketo and get Marketo certified by attending University Day, where you’ll learn about the market-leading marketing automation tool through a series of workshops and presentations.

Some big names will be there (previous years’ speakers included Arianna Huffington and Will Smith), as will 6k+ marketers, so you won’t want to miss out!

7. C2 Montreal: May 24-26 (Montreal, QC)

c2montreal

Much like its host city, C2 Montreal is a fusion of creativity and commerce. This three-day international business conference, dubbed the most innovative of its kind, focuses on exploring the impact of current digital trends on business. It will get you thinking outside of the box to reignite your creativity and change the way you do business for the better.

Expect to be challenged and connect with your peers in innovative ways. Expect to come away with a new way of thinking and plenty of inspiration. Expect to discover how marketers will adapt as digital evolves.

8. WistiaFest: June 11-13, (Boston)

wistiafest

This Boston-based event, run by Wistia, is a coming together of the great minds in video marketing. Why should you care? Video marketing is recognized to be one of the most effective marketing tools out there, and WistiaFest will teach you all you need to know about this medium including future trends and, most importantly, how to create ludicrously effective videos for your business. And going by what last year’s attendees tweeted, you’re in for a visual spectacle and an all-round cracking time.

9. Unbounce Call To Action Conference: June 25-27 (Vancouver, BC)

ctaconf_blogpost2

Familiar with the Unbounce blog? Then you’ll know that Unbounce is all about giving marketers actionable advice across the hottest topics in marketing and — just as importantly — providing a truly delightful experience.

CTAConf is like the Unbounce blog on steroids, featuring some of the best people in the business to give 100% fluff-free, practical tips that attendees can bring into play the next day. And you can be assured there will be a LOT of laughs throughout the day. Prepare to walk away from the day with a shedload of invaluable notes and some hilarious anecdotes.

Thinking of attending CTAConf 2017?

Subscribe to Unbounce Events and get exclusive discounts and the latest conference updates delivered to your inbox.

10. MozCon: July 17-19 (Seattle)

mozcon

MozCon is hosted by search engine marketing powerhouse Moz. (If you’re a marketer who doesn’t know Moz, it’s time to crawl out from that rock you’ve been hiding under.)

Get on top of your search marketing game and learn what’s hot in the world of SEO, social media and community building, straight from the mouths of industry leaders. This is a three-day conference that promises tons of actionable takeaways and socializing opportunities including MozCon’s very own pub crawl, #Mozcrawl. Hop on for some free drinks and great banter.

11. Content Marketing World: September 5-8 (Cleveland)

cmw2017

Content writers far and wide, this is your cue get excited. The biggest gathering of content marketing front runners, CMWorld will give you an overview of upcoming content marketing trends and plenty of ideas for rolling out an effective content strategy. Over the two days, you’ll have a ton of opportunities to network with the industry leaders and your fellow content peers.

12. Dmexco Conference: Sept 13-14 (Cologne, DE)

dmexco

Taking place in the historical German city of Cologne, Dmexco Conference is a two-day event defined as the “global meeting point for the digital economy”. A truly global conference, Dmexco is an outstanding opportunity to meet some digital economy big dogs from some leading global companies (think Bloomberg and Google). Keynotes, seminars and work labs that cover diverse themes in digital are offered in English or German.

13. INBOUND: September 25-28 (Boston)

inbound

Inbound is a mammoth-sized four-day event with over 19,000 attendees and a star-studded list of speakers (last year’s line-up included Anna Kendrick, Alec Baldwin and Serena Williams). It’s an opportunity for sales and marketing pros to rub shoulders with some of the biggest names in the industry and get tips and inspo on taking a business to the next level.

Four days jam-packed with talks, keynotes, workshops, some serious networking and partying. This year’s event promises to be bigger and better than ever.

14. B2B Forum: October 3-6 (Boston)

b2bforum

MarketingProf’s B2B Forum promises to give you the knowledge you need to build a sustainable marketing strategy. Headed up by Ann Handley, it’s also a unique opportunity to network with B2B businesses from across the globe and learn from their successes.

This event is pretty unique as it offers full-day workshops on one of four marketing topics (to be confirmed). So if you want to learn a lot and fast, come along for a marketing crash course.

15. RD Summit: November 2017 (Brazil)

rdsummit

RD Summit in Brazil is the biggest marketing and sales event in Latin America. With more than 5,000 attendees, 50 exhibitors and 120 presentations, this is a large-scale event, yet organized to the finest detail.

If you’re looking to get solid advice on your inbound marketing and sales strategy and network with a large community of marketers, why not head to Brazil in November? Plus, you can sample the delights of the vibrant Brazilian culture, including its iconic food and long beaches.

16. Dreamforce: November 6-9 (San Francisco)

dreamforce

Dreamforce is a behemoth of a conference that attracted nearly 200,000 attendees from over 83 countries last year. We simply couldn’t leave it off the list for its sheer size!

Run by Salesforce, Dreamforce promises to adorn you with the knowledge you need to significantly increase your ROI. Marketers will learn ways to create amazing brand experiences and better connect with customers. They’ll also discover how to make the most of Salesforce in their marketing strategy. With over 2,000 sessions, there’s something for everyone, whether you’re an SMB or a Fortune 500 company. Just make sure you check out the agenda beforehand to select the content that’s relevant to you.

17. Internet Summit: November 15-16 (Raleigh)

internetsummit

Internet Summit is a forum that brings together a whole host of thought leaders in the field of digital commerce.

If you’re looking for practical solutions to apply to your marketing, analytics and user experience strategies and to learn about the latest trends in digital technology, this event has got your covered. And get ready to network with some of the world’s leading brands including Facebook, AOL and The Onion.

BONUS! Advocamp: December 6-8 (San Francisco)

advocamp

You know the old adage: it can cost 5x more acquiring a new customer than retaining an existing one. This is why we recommend Advocamp — a conference that’s all about the customer experience.

Although not strictly a marketing event, Advocamp will give you some great ideas on engaging your current following and fostering a loyal customer base. After all, your marketing efforts will become even more valuable if your leads become happy, long-term customers and advocates of your brand.

There were some top-notch speakers from leading global companies last year including world-class author Daniel Pink and “The most re-tweeted person in the world among digital marketers” Jay Baer. Expect the same in 2017.

Over to you

Whether you’re a content writer, SEO buff or PPC manager, 2017 has got a standout marketing event that can give you the knowledge and contacts you need to be an even better marketer.

So if you’re set on making 2017 your most successful year yet, we encourage you to bite the bullet and sign up for the most relevant event for you. You’ve got nothing to lose and a whole notebook’s worth of valuable insider industry information to gain.

Is a certain awesome marketing conference missing from this list? Don’t be shy. Share it with us in the comments section below.

Jump to original:

The 17 Best Digital Marketing Conferences of 2017

How To Build A SpriteKit Game In Swift 3 (Part 1)

Have you ever wondered what it takes to create a SpriteKit game from beginning to beta? Does developing a physics-based game seem daunting? Game-making has never been easier on iOS since the introduction of SpriteKit.

How To Build A SpriteKit Game In Swift 3 (Part 1)

In this three-part series, we will explore the basics of SpriteKit. We will touch on SKPhysics, collisions, texture management, interactions, sound effects, music, buttons and SKScenes. What might seem difficult is actually pretty easy to grasp. Stick with us while we make RainCat.

The post How To Build A SpriteKit Game In Swift 3 (Part 1) appeared first on Smashing Magazine.

View original:

How To Build A SpriteKit Game In Swift 3 (Part 1)

Disrupting the norm: 4 ways to tap into your team’s creativity

Reading Time: 6 minutes

It’s easy to get stuck in a work routine.

To go to the office every Monday to Friday, use a particular set of skills, sit at the same desk, talk to the same team members, eat at the same lunch spot…

While routine can be a stabilizing force, it can also lead to stagnation and a lack of inspiration (a worrisome situation for any marketer).

Companies take great care to put structures in place to improve productivity and efficiency, but too often de-prioritize creativity. And yet, creativity is essential to driving innovation and competition—two vital components of business growth.

At WiderFunnel, we believe in the Zen Marketing mindset. This mindset recognizes that there is an intuitive, inspired, exploratory side to marketing that imagines potential insights, as well as a qualitative, logical, data-driven side that proves whether the insights really work.

In order to come up with the very best ideas to test, you must have room to get creative.

So, how can you make creativity a priority at your company?

Last month, the WiderFunnel team set out to answer that question for ourselves. We went on a retreat to one of British Columbia’s most beautiful islands, with the goal of learning how to better tap into and harness our creativity, as individuals and as a team.

creativity_setting
It’s hard to not be creative with a view like this.

We spent three days trying to unleash our creative sides, and the tactics we brought back to the office have had exciting effects! In this post, I’m going to share four strategies that we have put into practice at WiderFunnel to help our team get creative, that you can replicate in your company today.

As Jack London said,

You can’t wait for inspiration. You have to go after it with a club.

An introduction to creativity

There are many ways to think about creativity, but for our purposes, let’s consider the two types of creativity: technical creativity and artistic creativity. The former refers to the creation of new theories, new technologies, and new ideas. The latter revolves around skills, technique, and self-expression.

As a company, we were focused on tapping into technical creativity on our retreat. One of the main elements of technical creativity is lateral thinking.

Your brain recognizes patterns: faces, language, handwriting. This is beneficial in that you can recognize an object or a situation very quickly (you see a can of Coke and you know exactly what it is without having to analyze it).

But, we can get stuck in our patterns. We think within patterns. We problem-solve within patterns. Often, the solutions we come up with are based on solutions we’ve already come up with to similar problems. And we do this without really knowing that our solutions belong to other patterns.

Lateral thinking techniques can help you bust out of this…well…pattern.

While structured, disciplined thinking is vital to making your products and services better, lateral thinking can help you come up with completely new concepts and unexpected solutions.

The following 4 tactics will help you think laterally at work, to find truly original solutions to problems.

1. Put on a different (thinking) hat

One of our first activities on the island was to break into groups and tackle an internal company challenge with the six thinking hats. Developed by Edward de Bono, the “six thinking hats” is a tool for group discussion and individual thinking.

The idea behind the six hats is that our brains think in distinct ways that we can deliberately challenge. Each hat represents a direction in which the brain can be challenged. When you ‘put on a different hat’, your brain will identify and bring into conscious thought certain aspects of the problem you’re trying to solve, according to your hat.

6-hats-creativity
The Six Thinking Hats.

None of these hats represent completely natural ways of thinking, but rather how some of us already represent the results of our thinking.

In our exercise, we began a discussion each wearing one of the six hats. As the conversation progressed, we were forced to switch hats and continue our discussion from entirely different perspectives. It was uncomfortable and challenging, but the different hats forced each of us to explore the problem in a way that was totally alien.

creativity_thinkinghats
Before we could have our discussion, we had to make our own thinking hats.
Our thinking cards.
Our thinking cards.

The outcome was exciting: people who are normally quiet were forced to manage a discussion, people who are normally incredulous were forced to be optimistic, people who are normally dreamers were forced to ask for facts…it opened up totally new doors within the discussion.

In WiderFunnel’s main meeting room, there are six cards that represent each of the six hats. Whenever I find myself stuck, dealing with a challenge I can’t seem to solve, I wander into that meeting room and try to tackle the problem ‘wearing each hat’. Disrupting my normal thinking patterns often leads to ‘A-ha!’ moments.

To encourage lateral thinking, you could: create something physical and tangible (cards, hats, etc.) that your team can utilize when they are stuck to challenge the ‘normal’ ways in which they think.

2. Solve puzzles (literally)

A man jumps out of a window of a 30-story building. He falls all the way to the ground and lands on solid concrete with nothing to cushion his fall, yet he is completely uninjured. How is this possible?

There are 20 birds on a fence. A woman shoots one of the birds. How many birds are left?

There is an egg carton holding a dozen eggs on a table. Twelve people take one egg each, but there is still one egg left in the carton. How?

During our retreat, we spent some time solving word problems just like these, in order to disrupt our day-to-day thinking patterns.

creativity_puzzle
A recently completed WiderFunnel puzzle!

Riddles like these challenge our brains because they are difficult to think through using straightforward logic. Instead, you have to think outside of the content within the puzzle and use your knowledge of language and experience to solve it.

Puzzles require you to use reasoning that is not immediately obvious, and involve ideas that you may not arrive at using traditional step-by-step logic.

When you are faced with a puzzle like one of the riddles above, your mind is forced to think critically about something you might otherwise dismiss or fail to understand completely.

The thinking involved in solving puzzles can be characterized as a blend of imaginative association and memory. It is this blend…that leads us to literally see the pattern or twist that a puzzle conceals. It is a kind of “clairvoyance” that typically provokes an Aha! effect.

– Marcel Danesai, Ph.D. in “Puzzles and the Brain

To encourage creative, critical thinking, you could: incorporate puzzles into your day-to-day. Email your team a word problem every morning, or set up a physical puzzle somewhere in your office, so that people can take puzzle breaks!

3. Unpack your assumptions

Often, when we are faced with a question or problem, we have already classified that question or problem by its perceived limitations or rules. For example, you have assumptions about your users (most likely backed by data!) about what they want and need, what their pain points are, etc.

But, these assumptions, even if they are correct, can sometimes blind you to other possibilities. Unpacking your assumptions involves examining all of your assumptions, and then flipping them upside down. This can be tough because our assumptions are often deeply ingrained.

On the island, WiderFunnel-ers listed out all of our assumptions about what our clients want. At the top of that list was an assumption about what every marketer wants: to increase ROI. When we flipped that assumption, however, we were left with a hypothetical situation in which our clients don’t care at all about ROI.

creativity_assumptions
Various WiderFunnel-ers unpacking their assumptions.

All of a sudden, we were asking questions about what we might be able to offer our clients that has nothing to do with increasing ROI. While this hypothetical is an extreme, it forced us to examine all of the other areas where we might be able to help our clients.

To encourage creative problem-solving, you could: advise your team to list out all of their assumptions about a problem, flip ‘em, and then look for the middle ground.

4. Think of the dumbest idea you possibly can

The worst enemy to creativity is self-doubt.

– Sylvia Plath

To wrap up day 1 of our retreat, we did an activity called Dumbest Idea First. We walked around in a circle in the sunshine, shouting out the dumbest ideas we could think of about how to encourage more creativity at WiderFunnel.

The circle was quiet at first. Because being dumb, sounding dumb, looking dumb is scary. But, after a few people yelled out some really, really dumb ideas, everyone got into it. We were all moving, and making ridiculous suggestions, and in the midst of it all, one person would shout out a gem of an idea.

For instance, someone suggested a ‘brainstorm bubble’: a safe space within the office where you can go when you’re stuck, and your co-workers can see you and join you in the bubble to help you brainstorm.

(We have since started doing this at the office and it has been awesome!)

I don’t know about you, but I sometimes limit myself during a brainstorm—I find myself trying to be creative while still being pragmatic.

But, when you give yourself permission to be dumb, all of a sudden the possibilities are endless. And I guarantee you will surprise yourself with the great ideas you stumble upon.

Encourage creativity by allowing yourself and your team time and space to be unapologetically dumb.

What are some of the strategies you use to keep things creative at your company? Have you tried or improved upon any of the aforementioned strategies? Let us know in the comments!

The post Disrupting the norm: 4 ways to tap into your team’s creativity appeared first on WiderFunnel Conversion Optimization.

Excerpt from: 

Disrupting the norm: 4 ways to tap into your team’s creativity

Thumbnail

A/B Testing Copy on Homepage Increased Leads by 69% [Case Study]

The Company

VenueSphere is an online third-party referral business that helps individuals and companies find a perfect venue for parties, meetings, conferences and other events. They are based out of London and their service is completely free for visitors.

To capture leads, they have a neat and simple form above the fold on their homepage. The headline, just above the form, “Looking for a venue in London?” describes the value proposition aptly. The headline is accompanied by a sub-headline that originally read, “Call us or fill in a form to speak to a dedicated venue coordinator”. This is how it looked on their homepage:

VenueSphere A/B testing control

The Test

Quoting Ben at Venue Sphere, “Our homepage is fairly broad – it doesn’t perform brilliantly in getting conversions because it’s not very focused. So I wanted to get people’s attention, so they read more about what we do.” And so he decided to play around with the sub-headline in an attempt to increase the leads they were getting. He wanted to try something more dynamic and attention-grabbing. The new sub-headline read, “Stop right now! Call us or fill in the form and we’ll do the hard work for you for free” which he set up for test with VWO.

The goal that they were tracking with VWO was the visit to the thank-you page (that appears when people fill the contact form), which is equal to the number of leads from the form.

This is how the new sub-headline looked on the homepage:

variation1

The Result

Close to 1200 visitors became a part of this test and the variation emerged as the winner. The new sub-headline recorded a whopping 69% increase in leads.

Ben had also integrated the test with Google Analytics and he also added, “I was also able to see that our phone conversions were better with the variation, as was time on site, pages per visit and bounce rate.”

Here’s a quick comparison image showing the control and variation:

VenueSphere A/B testing comparison image

Why the Variation Won

To understand why the variation was able to get 69% more leads, let’s deconstruct the new sub-headline into three parts:

Part 1: “Stop right now! Call us or fill in the form”

After reading the headline, this part in the sub-headline clearly directs the visitors what do they have to do next. The “Stop right now” phrase with an exclamation at the end though sounds abrupt or forceful but it definitely got visitors’ attention. Quoting Ben, “I was concerned that it might be too forceful, that it might put people off, but that didn’t seem to be the case. I think that there is a strong case for saying that users want to be told what to do in certain situations”

Part 2: “and we’ll do the hard work”

This phrase assures the user that VenueSphere takes complete responsibility of helping them find the perfect venue. It also directly lets the visitors know that finding the most delightful venue could be lot of hard work and VenueSphere would do it all for them.

Part 3: “for free.”

And comes my favorite and the game-changing part! The magical word “free” finally lets the visitors know that they just have to fill the form and the company will help them find the perfect venue. At absolutely no cost.

Another customer of VWO was able to increase their conversion rate by 28% by adding the word “free”. Read the full A/B testing case study here.

I am not sure which part motivated the visitors most. The first where they were directed what-next, or next when the company took complete responsibility for them, or the last — that it was all for free! But I would definitely love to see VenueSphere perform more tests where they test these messages and understand what is it that their visitors care about most — the fact that the service is free or that they don’t have to do absolutely anything to find a venue.

Tell me what do you think! Let’s talk in the comments section below.

Bonus: You should also read this absolutely insightful article from the VWO blog where Anand gives 10 tips to write headlines that convert.

The post A/B Testing Copy on Homepage Increased Leads by 69% [Case Study] appeared first on VWO Blog.

Read the article:

A/B Testing Copy on Homepage Increased Leads by 69% [Case Study]

Thumbnail

Building A Simple Cross-Browser Offline To-Do List With IndexedDB And WebSQL

Making an application work offline can be a daunting task. In this article, Matthew Andrews, a lead developer behind FT Labs, shares a few insights he had learned along the way while building the FT application. Matthew will also be running a “Making It Work Offline” workshop1 at our upcoming Smashing Conference in Freiburg in mid-September 2014. – Ed.

We’re going to make a simple offline-first to-do application2 with HTML5 technology. Here is what the app will do:

  • store data offline and load without an Internet connection;
  • allow the user to add and delete items in the to-do list;
  • store all data locally, with no back end;
  • run on the first- and second-most recent versions of all major desktop and mobile browsers.

The complete project is ready for forking on GitHub3.

Which Technologies To Use

In an ideal world, we’d use just one client database technology. Unfortunately, we’ll have to use two:

Veterans of the offline-first world might now be thinking, “But we could just use localStorage6, which has the benefits of a much simpler API, and we wouldn’t need to worry about the complexity of using both IndexedDB and WebSQL.” While that is technically true, localStorage has number of problems7, the most important of which is that the amount of storage space available with it is significantly less than IndexedDB and WebSQL.

Luckily, while we’ll need to use both, we’ll only need to think about IndexedDB. To support WebSQL, we’ll use an IndexedDB polyfill8. This will keep our code clean and easy to maintain, and once all browsers that we care about support IndexedDB natively, we can simply delete the polyfill.

Note: If you’re starting a new project and are deciding whether to use IndexedDB or WebSQL, I strongly advocate using IndexedDB and the polyfill. In my opinion, there is no reason to write any new code that integrates with WebSQL directly.

I’ll go through all of the steps using Google Chrome (and its developer tools), but there’s no reason why you couldn’t develop this application using any other modern browser.

1. Scaffolding The Application And Opening A Database

We will create the following files in a single directory:

  • /index.html
  • /application.js
  • /indexeddb.shim.min.js
  • /styles.css
  • /offline.appcache

/index.html

<!DOCTYPE html>
<html>
  <head>
    <link rel='stylesheet' href='./styles.css' type='text/css' media='all' />
  </head>
  <body>
    <h1>Example: Todo</h1>
    <form>
      <input placeholder="Type something" />
    </form>
    <ul>
    </ul>
    <script src="./indexeddb.shim.min.js"></script>
    <script src="./application.js"></script>
  </body>
</html>

Nothing surprising here: just a standard HTML web page, with an input field to add to-do items, and an empty unordered list that will be filled with those items.

/indexeddb.shim.min.js

Download the contents of the minified IndexedDB polyfill9, and put it in this file.

/styles.css

body 
  margin: 0;
  padding: 0;
  font-family: helvetica, sans-serif;


* 
  box-sizing: border-box;


h1 
  padding: 18px 20px;
  margin: 0;
  font-size: 44px;
  border-bottom: solid 1px #DDD;
  line-height: 1em;


form 
  padding: 20px;
  border-bottom: solid 1px #DDD;


input 
  width: 100%;
  padding: 6px;
  font-size: 1.4em;


ul 
  margin: 0;
  padding: 0;
  list-style: none;


li 
  padding: 20px;
  border-bottom: solid 1px #DDD;
  cursor: pointer;

Again, this should be quite familiar: just some simple styles to make the to-do list look tidy. You may choose not to have any styles at all or create your own.

/application.js

(function() 

  // 'global' variable to store reference to the database
  var db;

  databaseOpen(function() 
    alert("The database has been opened");
  );

  function databaseOpen(callback) 
    // Open a database, specify the name and version
    var version = 1;
    var request = indexedDB.open('todos', version);

    request.onsuccess = function(e) 
      db = e.target.result;
      callback();
    ;
    request.onerror = databaseError;
  }

  function databaseError(e) 
    console.error('An IndexedDB error has occurred', e);
  

}());

All this code does is create a database with indexedDB.open and then show the user an old-fashioned alert if it is successful. Every IndexedDB database needs a name (in this case, todos) and a version number (which I’ve set to 1).

To check that it’s working, open the application in the browser, open up “Developer Tools” and click on the “Resources” tab.

In the Resources panel, you can check whether it's working.
In the “Resources” panel, you can check whether it’s working.

By clicking on the triangle next to “IndexedDB,” you should see that a database named todos has been created.

2. Creating The Object Store

Like many database formats that you might be familiar with, you can create many tables in a single IndexedDB database. These tables are called “objectStores.” In this step, we’ll create an object store named todo. To do this, we simply add an event listener on the database’s upgradeneeded event.

The data format that we will store to-do items in will be JavaScript objects, with two properties:

  • timeStamp
    This timestamp will also act as our key.
  • text
    This is the text that the user has entered.

For example:

 timeStamp: 1407594483201, text: 'Wash the dishes' 

Now, /application.js looks like this (the new code starts at request.onupgradeneeded):

(function() 

  // 'global' variable to store reference to the database
  var db;

  databaseOpen(function() 
    alert("The database has been opened");
  );

  function databaseOpen(callback) 
    // Open a database, specify the name and version
    var version = 1;
    var request = indexedDB.open('todos', version);

    // Run migrations if necessary
    request.onupgradeneeded = function(e) 
      db = e.target.result;
      e.target.transaction.onerror = databaseError;
      db.createObjectStore('todo',  keyPath: 'timeStamp' );
    };

    request.onsuccess = function(e) 
      db = e.target.result;
      callback();
    ;
    request.onerror = databaseError;
  }

  function databaseError(e) 
    console.error('An IndexedDB error has occurred', e);
  

}());

This will create an object store keyed by timeStamp and named todo.

Or will it?

Having updated application.js, if you open the web app again, not a lot happens. The code in onupgradeneeded never runs; try adding a console.log in the onupgradeneeded callback to be sure. The problem is that we haven’t incremented the version number, so the browser doesn’t know that it needs to run the upgrade callback.

How to Solve This?

Whenever you add or remove object stores, you will need to increment the version number. Otherwise, the structure of the data will be different from what your code expects, and you risk breaking the application.

Because this application doesn’t have any real users yet, we can fix this another way: by deleting the database. Copy this line of code into the “Console,” and then refresh the page:

indexedDB.deleteDatabase('todos');

After refreshing, the “Resources” pane of “Developer Tools” should have changed and should now show the object store that we added:

The Resources panel should now show the object store that was added.
The “Resources” panel should now show the object store that was added.

3. Adding Items

The next step is to enable the user to add items.

/application.js

Note that I’ve omitted the database’s opening code, indicated by ellipses (…) below:

(function() 

  // Some global variables (database, references to key UI elements)
  var db, input;

  databaseOpen(function() 
    input = document.querySelector('input');
    document.body.addEventListener('submit', onSubmit);
  );

  function onSubmit(e) 
    e.preventDefault();
    databaseTodosAdd(input.value, function() 
      input.value = '';
    );
  }

[…]

  function databaseTodosAdd(text, callback) 
    var transaction = db.transaction(['todo'], 'readwrite');
    var store = transaction.objectStore('todo');
    var request = store.put(
      text: text,
      timeStamp: Date.now()
    );

    transaction.oncomplete = function(e) 
      callback();
    ;
    request.onerror = databaseError;
  }

}());

We’ve added two bits of code here:

  • The event listener responds to every submit event, prevents that event’s default action (which would otherwise refresh the page), calls databaseTodosAdd with the value of the input element, and (if the item is successfully added) sets the value of the input element to be empty.
  • A function named databaseTodosAdd stores the to-do item in the local database, along with a timestamp, and then runs a callback.

To test that this works, open up the web app again. Type some words into the input element and press “Enter.” Repeat this a few times, and then open up “Developer Tools” to the “Resources” tab again. You should see the items that you typed now appear in the todo object store.

03-step3-dev-tools-opt-50010
After adding a few items, they should appear in the todo object store. (View large version11)

4. Retrieving Items

Now that we’ve stored some data, the next step is to work out how to retrieve it.

/application.js

Again, the ellipses indicate code that we have already implemented in steps 1, 2 and 3.

(function() 

  // Some global variables (database, references to key UI elements)
  var db, input;

  databaseOpen(function() 
    input = document.querySelector('input');
    document.body.addEventListener('submit', onSubmit);
    databaseTodosGet(function(todos) 
      console.log(todos);
    );
  });

[…]

  function databaseTodosGet(callback) 
    var transaction = db.transaction(['todo'], 'readonly');
    var store = transaction.objectStore('todo');

    // Get everything in the store
    var keyRange = IDBKeyRange.lowerBound(0);
    var cursorRequest = store.openCursor(keyRange);

    // This fires once per row in the store. So, for simplicity,
    // collect the data in an array (data), and pass it in the
    // callback in one go.
    var data = [];
    cursorRequest.onsuccess = function(e) 
      var result = e.target.result;

      // If there's data, add it to array
      if (result) 
        data.push(result.value);
        result.continue();

      // Reach the end of the data
       else 
        callback(data);
      
    };
  }

}());

After the database has been initialized, this will retrieve all of the to-do items and output them to the “Developer Tools” console.

Notice how the onsuccess callback is called after each item is retrieved from the object store. To keep things simple, we put each result into an array named data, and when we run out of results (which happens when we’ve retrieved all of the items), we call the callback with that array. This approach is simple, but other approaches might be more efficient.

If you reopen the application again, the “Developer Tools” console should look a bit like this:

The console after reopening the application
The console after reopening the application

5. Displaying Items

The next step after retrieving the items is to display them.

/application.js

(function() 

  // Some global variables (database, references to key UI elements)
  var db, input, ul;

  databaseOpen(function() 
    input = document.querySelector('input');
    ul = document.querySelector('ul');
    document.body.addEventListener('submit', onSubmit);
    databaseTodosGet(renderAllTodos);
  );

  function renderAllTodos(todos) 
    var html = '';
    todos.forEach(function(todo) 
      html += todoToHtml(todo);
    );
    ul.innerHTML = html;
  }

  function todoToHtml(todo) 
    return '<li>'+todo.text+'</li>';
  

[…]

All we’ve added are a couple of very simple functions that render the to-do items:

  • todoToHtml
    This takes a todos object (i.e. the simple JavaScript object that we defined earlier).
  • renderAllTodos
    This takes an array of todos objects, converts them to an HTML string and sets the unordered list’s innerHTML to it.

Finally, we’re at a point where we can actually see what our application is doing without having to look in “Developer Tools”! Open up the app again, and you should see something like this:

Your application in the front-end view12
Your application in the front-end view (View large version13)

But we’re not done yet. Because the application only displays items when it launches, if we add any new ones, they won’t appear unless we refresh the page.

6. Displaying New Items

We can fix this with a single line of code.

/application.js

The new code is just the line databaseTodosGet(renderAllTodos);.

[…]

function onSubmit(e) 
  e.preventDefault();
  databaseTodosAdd(input.value, function() 
    // After new items have been added, re-render all items
    databaseTodosGet(renderAllTodos);
    input.value = '';
  );
}

[…]

Although this is very simple, it’s not very efficient. Every time we add an item, the code will retrieve all items from the database again and render them on screen.

7. Deleting Items

To keep things as simple as possible, we will let users delete items by clicking on them. (For a real application, we would probably want a dedicated “Delete” button or show a dialog so that an item doesn’t get deleted accidentally, but this will be fine for our little prototype.)

To achieve this, we will be a little hacky and give each item an ID set to its timeStamp. This will enable the click event listener, which we will add to the document’s body, to detect when the user clicks on an item (as opposed to anywhere else on the page).

/application.js

(function() 

  // Some global variables (database, references to key UI elements)
  var db, input, ul;

  databaseOpen(function() 
    input = document.querySelector('input');
    ul = document.querySelector('ul');
    document.body.addEventListener('submit', onSubmit);
    document.body.addEventListener('click', onClick);
    databaseTodosGet(renderAllTodos);
  );

  function onClick(e) 

    // We'll assume that any element with an ID
    // attribute is a to-do item. Don't try this at home!
    if (e.target.hasAttribute('id')) 

      // Because the ID is stored in the DOM, it becomes
      // a string. So, we need to make it an integer again.
      databaseTodosDelete(parseInt(e.target.getAttribute('id'), 10), function() 

        // Refresh the to-do list
        databaseTodosGet(renderAllTodos);
      );
    }
  }

[…]

  function todoToHtml(todo) 
    return '<li id="'+todo.timeStamp+'">'+todo.text+'</li>';
  

[…]

  function databaseTodosDelete(id, callback) {
    var transaction = db.transaction(['todo'], 'readwrite');
    var store = transaction.objectStore('todo');
    var request = store.delete(id);
    transaction.oncomplete = function(e) 
      callback();
    ;
    request.onerror = databaseError;
  }

}());

We’ve made the following enhancements:

  • We’ve added a new event handler (onClick) that listens to click events and checks whether the target element has an ID attribute. If it has one, then it converts that back into an integer with parseInt, calls databaseTodosDelete with that value and, if the item is successfully deleted, re-renders the to-do list following the same approach that we took in step 6.
  • We’ve enhanced the todoToHtml function so that every to-do item is outputted with an ID attribute, set to its timeStamp.
  • We’ve added a new function, databaseTodosDelete, which takes that timeStamp and a callback, deletes the item and then runs the callback.

Our to-do app is basically feature-complete. We can add and delete items, and it works in any browser that supports WebSQL or IndexedDB (although it could be a lot more efficient).

Almost There

Have we actually built an offline-first to-do app? Almost, but not quite. While we can now store all data offline, if you switch off your device’s Internet connection and try loading the application, it won’t open. To fix this, we need to use the HTML5 Application Cache14.

Warning

  • While HTML5 Application Cache works reasonably well for a simple single-page application like this, it doesn’t always. Thoroughly research how it works15 before considering whether to apply it to your website.
  • Service Worker16 might soon replace HTML5 Application Cache, although it is not currently usable in any browser, and neither Apple nor Microsoft have publicly committed to supporting it.

8. Truly Offline

To enable the application cache, we’ll add a manifest attribute to the html element of the web page.

/index.html

<!DOCTYPE html>
<html manifest="./offline.appcache">
[…]

Then, we’ll create a manifest file, which is a simple text file in which we crudely specify the files to make available offline and how we want the cache to behave.

/offline.appcache

CACHE MANIFEST
./styles.css
./indexeddb.shim.min.js
./application.js

NETWORK:
*

The section that begins CACHE MANIFEST tells the browser the following:

  • When the application is first accessed, download each of those files and store them in the application cache.
  • Any time any of those files are needed from then on, load the cached versions of the files, rather than redownload them from the Internet.

The section that begins NETWORK tells the browser that all other files must be downloaded fresh from the Internet every time they are needed.

Success!

We’ve created a quick and simple to-do app17 that works offline and that runs in all major modern browsers, thanks to both IndexedDB and WebSQL (via a polyfill).

Resources

(al, ml, il)

Footnotes

  1. 1 http://smashingconf.com/workshops/matthew-andrews
  2. 2 https://matthew-andrews.github.io/offline-todo/
  3. 3 https://github.com/matthew-andrews/offline-todo
  4. 4 http://caniuse.com/indexeddb
  5. 5 http://caniuse.com/sql-storage
  6. 6 http://caniuse.com/namevalue-storage
  7. 7 https://hacks.mozilla.org/2012/03/there-is-no-simple-solution-for-local-storage/
  8. 8 https://github.com/axemclion/IndexedDBShim
  9. 9 https://raw.githubusercontent.com/matthew-andrews/offline-todo/gh-pages/indexeddb.shim.min.js
  10. 10 http://www.smashingmagazine.com/wp-content/uploads/2014/08/03-step3-dev-tools-opt.jpg
  11. 11 http://www.smashingmagazine.com/wp-content/uploads/2014/08/03-step3-dev-tools-opt.jpg
  12. 12 http://www.smashingmagazine.com/wp-content/uploads/2014/08/05-step5-app-opt.jpg
  13. 13 http://www.smashingmagazine.com/wp-content/uploads/2014/08/05-step5-app-opt.jpg
  14. 14 https://developer.mozilla.org/en-US/docs/Web/HTML/Using_the_application_cache
  15. 15 http://alistapart.com/article/application-cache-is-a-douchebag
  16. 16 http://www.serviceworker.org/
  17. 17 https://matthew-andrews.github.io/offline-todo/
  18. 18 http://www.html5rocks.com/en/tutorials/indexeddb/todo/
  19. 19 http://nparashuram.com/IndexedDBShim/
  20. 20 http://alistapart.com/article/application-cache-is-a-douchebag
  21. 21 https://jakearchibald.github.io/isserviceworkerready/

The post Building A Simple Cross-Browser Offline To-Do List With IndexedDB And WebSQL appeared first on Smashing Magazine.

See more here:  

Building A Simple Cross-Browser Offline To-Do List With IndexedDB And WebSQL