0

I am trying to create a website. I use Jquery and PHP for server-side and MySQL for database.Now thats one of my PHP files.

//header.php
<div class="d-flex justify-content-start flex-wrap">
<div id="today" class="gal1">today</div>
<div id="history" class="gal1 <?php echo empty( $user ) ? 'mr-auto' : ''; ?>" data-toggle="modal" data-target="#dateModal">history</div>
<?php 
$stmt = $pdo->query("select isSeen from mail where isSeen = 0 and recipient = '$user'");
$lightUp = $stmt->rowCount() > 0 ? 'lightUp' : '';

if ( !empty( $user ) ) echo'<div id="me" class="gal1" onclick="location.href=\'http://localhost:180/anbu/someone.php?someone='.$user.'\'">@'.$user.'</div>
                            <div id="buddy" class="gal1" onclick="location.href=\'http://localhost:180/anbu/subs.php\'">buddy</div>
                            <div id="faves" class="gal1" onclick="location.href=\'http://localhost:180/anbu/faves.php\'">faves</div>
                            <div id="mbox" class="gal1 '.$lightUp.'" onclick="location.href=\'http://localhost:180/anbu/mbox.php\'">mBox</div>
                            <div id="options" class="gal1" onclick="location.href=\'http://localhost:180/anbu/options.php\'">options</div>
                            <div id="eight" class="mr-auto gal1" onclick=""><i class="fa fa-circle" style="color:blue;"></i></div>';

if ( empty( $user ) )  echo'<a class="gal2" href="http://localhost:180/anbu/log-in.php">log in</a>
                            <a class="gal2" href="http://localhost:180/anbu/sign-up.php">sign up</a>';
else
                       echo'<a class="gal2" href="http://localhost:180/anbu/userWorks/log-out.php">log out</a>';
?>

How to compress this code so my server won't have to send all the space characters? Is there a program for this kind of jobs? Yes, my first website and i am a newbie.

Gai Kuroda
  • 80
  • 1
  • 12
  • 5
    That's a useless optimization. – u_mulder Mar 22 '18 at 11:49
  • Just replace two-spaces with single-space. This should not break your code and it will reduce the script size. – ino Mar 22 '18 at 11:49
  • @ino my codes should be understandable. simplified files will be stored on the server. didn't u get the question? – Gai Kuroda Mar 22 '18 at 11:52
  • 1
    have your webserver gzip the response payload. For example under apache https://httpd.apache.org/docs/2.4/mod/mod_deflate.html You then have to weight up CPU vs Bandwidth. – Scuzzy Mar 22 '18 at 11:53
  • @Scuzzy i am buying server today hopefully. Do they have tools? – Gai Kuroda Mar 22 '18 at 11:54
  • @AgniusVasiliauskas yes thats exactly what iam trying to ask. and i learned it. Gzip compresion inside .htaccess. however i still have to compress JS and CSS files with a different program right? – Gai Kuroda Mar 22 '18 at 12:11

1 Answers1

0

Please try to learn any MVC framework for php. Project source code will be unmanageable if you continue writing like this.

Shibly
  • 23
  • 1
  • 7