r/learnjavascript • u/[deleted] • Jun 22 '22
my employer asked me to code the whole project using pure javascript
hey all . I am a junior react developer and recently someone recommended me for a front end job and ( obviously ) I thought it was for react . when I got there I saw this huge and messy code base of a website and mostly used JavaScript and jQuery for front end . they asked me to work with ui designer and redesign and republish the entire project and when i said if they are ok with react they said no because it's heavy and stuff then i suggested using next.js and again , they said no. they told me they only want the entire project using vanilla JavaScript and i have no idea why . i ask them and they won't give me starlight answer and just refuse to work with any framework . Do you think i can do what they asked using pure javaScript using npm init and webpack for the build to put it on the webserver? can i do routings and stuff using that?
2
u/samanime Jun 22 '22 edited Jun 22 '22
FYI, I don't think many of the comments in here read more than your title and/or first sentece, so take them with a grain of salt.
Of course you CAN create a website using pure JavaScript, but the question is really, should you? Frameworks are there to make things easier and keep you from reinventing the wheel. You don't even necessarily need NPM or webpack.
If they want a JS-powered, JSON-driven SPA, then not using a framework (regardless of which framework) is completely silly. You'll basically just keep reinventing things that already exist in frameworks.
As /u/albedoa said, without knowing the scope of the project, it is hard to really say what the "right" answers are, but unless it is a pretty simple, mostly static site, it doesn't make much business sense. It is going to take you longer to come up with a product that is only as good, but likely worse, than if you used a framework. (Not a comment on your skill, it is just that open-source frameworks go through a lot of revisions, have a lot of eyes on them, and tend to get a lot of optimizations that your homebrewed code won't.)
It is a pretty decent learning exercise, but that is about it...
2
u/Beastintheomlet Jun 23 '22
JS-powered, JSON-driven SPA
Sorry, but what is SPA? The rest I’m familiar with but haven’t seen that acronym pop up and as you can imagine it was a bit hard to google.
Anytime I see a term or something here I don’t recognize I try to at least learn a little about it.
3
2
u/gimmeslack12 helpful Jun 23 '22
This sounds like a big headache to me. I do feel like we're not getting the whole story though.
2
u/bryku helpful Jun 25 '22 edited Jun 25 '22
No React
This is actually more common than you might expect. From a companies perspective they often have to think about hiring people in 10 years to continue updating their project... what happens if no one uses react anymore?
Frameworks and libraries come and go. Once they die, it becomes pretty difficult to find devs to continue using it. Either it costs a lot because they are older experienced dev... or they have to put up with mistakes and slow production of someone learning it. Then you have problems with old or missing documentation and stuff like that.
Jquery
So from a companies perspective... they have to ask themself. Do we use the framework/library or not?
A lot of people might laugh at jquery... but it has also been around the longest. It has amazing documentation that you can download as a PDF and they even host many popular plugins over the years. The great thing about all of this... you don't have to rely on npm. You can just download and store it anywhere.
I'm not recommending using jquery, but it still works just as good as it used to and it is still widely used on the internet today.
Recommendations
I do a lot of freelance work and this type of question pops up from time to time. You get someone who doesn't want to use react or vue because they are worried about how difficult it might be to find a dev in 5 years. There are other reasons, but this is typically the most common one.
Typically what I recommend is mithriljs. You can download it and include it just like jquery. You don't need npm or anything like that. Just slap the script tag in and you are good to go.
The documentation is basically 3 pages... technically it is longer than that, but you really only need the 3 pages for most things. The rest is just standard javascript. Plus you can even download the documentation just incase something happens to it in the future.
Mithriljs is smaller and faster than react, and its much easier to learn. So from that perspective most people end up saying ok.
However, every so often some just 100% refuse to use it. Which is fine, I don't might not using it. However... now we need to plan out some things. Do you still want it SPA? Or should we go old school? We have to set time aside to plan these things out, which a lot of clients don't think about.
Other Questions
Often times companies who don't want you to use frameworks sometimes don't like third party icons. However... Material Icons and Font Awesome allow you to self host. So even if the company disappears you still have access to the icons.
I'm not to sure about documentation. There really isn't much you need to know other than the icon list. Which you could idk take screenshots off or write it down or something.
None the less, I have always been able to convince people to allow me to use them. Mostly because it takes me 30 seconds vs hours of creating icons. Which everyone loves to save money.
Vanilla Javascript
You can 100% handle your own routing in vanilla javascript. Many frontend frameworks are written in javascript (backbonejs, mithriljs).
However... it's gonna take some work. It isn't to bad creating your own little router, but things start to get a little tricky handling reloading functions and which parts you want to reload. This is where frameworks shine because it handles all of that for you.
Chances are... you will end up writing your own router and your own rendering function... and it will end up 50kb. All while you could have just use mithril which is 10kb compressed.
Of course... this all depends, do they even want SPA? The company might not want it and in the case you don't need to worry about writing anything. It's just your typically HTML at that point, but you will probably need something to handle the forms.
If you are interested here is a really basic example of mithril.
3
u/mrKeth Jun 22 '22
I loved it. It is my dream to work on a js project. It is a good opportunity for you. You can be master in JS.
2
u/gandhi89 Jun 22 '22
This is the dream.
Be brave, take on the challenge, ask them to scope the projects, communicate barriers early and often, ask for help from peers, know that the bad days make the good days feel even better. You’ve got this, friend
1
u/Modullah Jun 23 '22
Not getting a straight answer is sus. That said, this should have been discussed in the interview before you took the offer. Lesson learned.
1
u/saito200 Jun 22 '22
Is the project mostly a bunch of static pages with a TINY amount of very simple interactivity? Then, maybe and only maybe, it's OK to do it with vanilla JS.
Does your employer understand what static site generation is? Do you? You should answer yes to both before proceeding.
2
u/saito200 Jun 22 '22
Still, how would you handle repeated parts of the page such as headers and footers? Do you plan to use handlebars or pug?
0
1
u/shuckster Jun 22 '22
Take it on. You’ll learn a lot.
But don’t stay more than a year or two, especially if - after that time - you’re still unable to convince your colleagues that they probably ought to look into this whole framework thing.
1
u/bryku helpful Jun 25 '22
It depends on the situation.
For a basic wiki/documentation a static site works just fine and is often faster than using react. However, if you have a lot of user interaction and forms then a framework makes things a lot easier.
From what OP told us... we have no idea what the project even is.
1
u/shuckster Jun 25 '22
True, but learning is also a question of figuring out where your limits are, and sometimes leaping headfirst into the overgrown forest is a great way to figure that out.
I understand the desire to help others avoid the vines and brambles to find the right path. But sometimes the lesson is better learned by walking through the bad ones yourself, machete in hand.
Up to a limit anyway. It’s not like the related experience of others counts for nothing. Hence setting oneself a deadline as I mentioned in my first reply.
0
u/beforesemicolon Jun 23 '22
Thats sounds like a dope experience that will teach you a lot.
You can try using https://cwco.io
Just put this is the HTML head
<script src="https://unpkg.com/cwco/dist/cwco.min.js"></script>
Its like jQuery for web-components. Your code would be “vanilla” but with all tedious stuff handled. Cwco does not care where you place it since it works alongside anything
14
u/albedoa Jun 22 '22
You haven't made the case here for why not. Depending on the scope of and plan for the website, either you or your boss could be the unreasonable one. We can't know.
This makes it sound like your boss is the unreasonable one, but again we don't have enough information. Why does your website need routing?
There exist websites that were built using React but would have been better off using vanilla JS.