0

In my new SPA (Single Page Application), I have teachers, which can make tests, and students, which can take tests, subscribe to teachers, and view their grades. This means that in JavaScript, they will both have very different actions they can do. But the HTML and CSS, incidentally, are very similar. My goal is to make the code maintainable and not have a slow load time. Obviously, I don't want to continue to do what I am currently doing, which is lumping the student and teacher code together and only calling what is needed. I'm thinking I will either

  • Create two pages, with each having their own (student/teacher).js/css files and common.js/css files
  • Continue to use one page, conditionally load Vue components for the different things students and teachers can do, and have different js/css files that will also be loaded conditionally.

I prefer the second option but I think that the page might be slowed because the app will have to wait for the first common files to load, then wait for authentication by the server to determine whether if a student or teacher account is logged in, and then load more css/js files.

Does anybody have a recommendation, or something different I should do?

  • 1
    I think this counts as a premature optimization. Won't the common files be cached by the browser? – James McLeod Jun 3 '18 at 13:23
1

If both groups — Sudents and Teachers — will consume the same app in the end, I'd definitely go the way of building one SPA. Especially Vue (and folks like React, Angular etc.) makes it easy to build customizable components. So your current user might have a role or type (student or teacher) and you might have pure teacher components, e.g. a grading component and pure student components, e.g. a submission component. But you might also have shared components, e.g. for messaging.

The term SPA is not adding constraints in regards to what you want to achieve. You can make it as multi-purpose as your data model requires. The term refers to the way of delivering your static files to the client (browser).

1

One thing to be careful of is if you create two pages and decide to make a change will you end up needing to make that change in two places?

Teachers will want to see what the students will see so you have good reasons to keep that code together. What you don't want is students seeing answers or editing the questions. That code should be able to work with the code both see.

As for authentication, both teachers and students need it. If take a test I want to get credit for it. So you're going to need that to work in a timely manner whatever you do.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.