EvanAgee / vuejs-wordpress-theme-starter

A WordPress theme with the guts ripped out and replaced with Vue.
https://vuewp.com/
1.6k stars 282 forks source link

Remove lodash #99

Closed simplenotezy closed 4 years ago

simplenotezy commented 4 years ago

I noticed you're pulling in lodash, but since you're using babel, why not stick to ES6?

For instance:

getPosts(limit, cb) {
  if (_.isEmpty(limit)) {
    let limit = 5;
  }

  axios
    .get(SETTINGS.API_BASE_PATH + "posts?per_page=" + limit)
    .then(response => {
      cb(response.data);
    })
    .catch(e => {
      cb(e);
    });
}

Could simply be:

getPosts(limit = 5, cb) {
  axios
    .get(SETTINGS.API_BASE_PATH + "posts?per_page=" + limit)
    .then({data} => {
      cb(data);
    })
    .catch(e => {
      cb(e);
    });
}

It would reduce filesize ;)

simplenotezy commented 4 years ago

Speaking of which; I don't see where / how loadash is being included - not present in the package.json or webpack file.

simplenotezy commented 4 years ago

Never mind; it was in package.json =)

EvanAgee commented 4 years ago

@simplenotezy yes this is on my list but I haven't had time yet. Interested in creating a PR to remove the dependency?

simplenotezy commented 4 years ago

Yes, I'll have a look at it @EvanAgee

simplenotezy commented 4 years ago

Just to have an idea of how much lodash takes:

image

EvanAgee commented 4 years ago

Yes, it's a big boy. I'll implement the tree shaking so at least it isn't larger than necessary.

simplenotezy commented 4 years ago

It's used sooo little it shouldn't take long time just to completely remove